News:

Looking for documentation? Take a look on our wiki

Main Menu

How to get Joomla Media field in custom plugin?

Started by Kuubs, April 12, 2024, 10:40:50 AM

Previous topic - Next topic

Kuubs

Hello,

I'm trying to make a plugin to add some fields to my product. But I'm not sure how to get media field in the following call:

function plgVmOnProductEdit($field, $productId, &$row, &$retValue) {
        if ($field->custom_element != $this->_name) return '';
 
        $html = ''; // Initialize HTML variable
   
       
   
        // Text field
        $html .= '<div>Text Field:</div>';
        $html .= '<textarea name="customfield_params['.$row.'][text_field]" style="width: 100%; height: 100px;">';
        $html .= htmlspecialchars($field->text_field);
        $html .= '</textarea><br/>';
   
        // First HTML editor field
        $editor = JFactory::getEditor();
        $html .= '<div>HTML Field 1:</div>';
        $html .= $editor->display('customfield_params['.$row.'][html_field1]', htmlspecialchars($field->html_field1), '100%', '200', '75', '20', false);
   
        // Media field
        $html .= '<div>Media Field:</div>';
       
        //HOW TO GET A MEDIA FIELD INSERTED HERE??
   
        $retValue .= $html;
        $row++;
        return true;
    }

Does anyone know what to call for this to work?