* @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; use Joomla\CMS\Helper\MediaHelper; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Router\Route; use Joomla\CMS\Uri\Uri; extract($displayData); /** * Layout variables * ----------------- * @var string $asset The asset text * @var string $authorField The label text * @var integer $authorId The author id * @var string $class The class text * @var boolean $disabled True if field is disabled * @var string $folder The folder text * @var string $id The label text * @var string $link The link text * @var string $name The name text * @var string $preview The preview image relative path * @var integer $previewHeight The image preview height * @var integer $previewWidth The image preview width * @var string $onchange The onchange text * @var boolean $readonly True if field is readonly * @var integer $size The size text * @var string $value The value text * @var string $src The path and filename of the image * @var array $mediaTypes The supported media types for the Media Manager * @var array $imagesExt The supported extensions for images * @var array $audiosExt The supported extensions for audios * @var array $videosExt The supported extensions for videos * @var array $documentsExt The supported extensions for documents * @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output * @var array $dataAttributes Miscellaneous data attribute for eg, data-* */ $attr = ''; // Initialize some field attributes. $attr .= !empty($class) ? ' class="form-control field-media-input ' . $class . '"' : ' class="form-control field-media-input"'; $attr .= !empty($size) ? ' size="' . $size . '"' : ''; $attr .= $dataAttribute; // Initialize JavaScript field attributes. $attr .= !empty($onchange) ? ' onchange="' . $onchange . '"' : ''; switch ($preview) { case 'no': // Deprecated parameter value case 'false': case 'none': $showPreview = false; break; case 'yes': // Deprecated parameter value case 'true': case 'show': case 'tooltip': default: $showPreview = true; break; } // Pre fill the contents of the popover if ($showPreview) { $cleanValue = MediaHelper::getCleanMediaFieldValue($value); if ($cleanValue && file_exists(JPATH_ROOT . '/' . $cleanValue)) { $src = Uri::root() . $value; } else { $src = ''; } $width = $previewWidth; $height = $previewHeight; $style = ''; $style .= ($width > 0) ? 'max-width:' . $width . 'px;' : ''; $style .= ($height > 0) ? 'max-height:' . $height . 'px;' : ''; $imgattr = array( 'id' => $id . '_preview', 'class' => 'media-preview', 'style' => $style, ); $img = HTMLHelper::_('image', $src, Text::_('JLIB_FORM_MEDIA_PREVIEW_ALT'), $imgattr); $previewImg = '