CoreFiles by mySites.guru
media.php53 lines, 1,190 bytes, from Joomla_4.0.4-Stable-Full_Package.zip
Raw History Compare with 4.0.3
md5
8c7bbb8495e2118dd40179a71d653b8c
sha1
328fdfdf9fb4dfe9bbe884f7f6499a7a1b1fe752
sha256
e6cb7b3e71af610246f1a4ca2e00ea56f121b2fb1aa9ee6a8309442c472c7d01
<?php
/**
 * @package     Joomla.Plugin
 * @subpackage  Fields.Media
 *
 * @copyright   (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;

if (empty($field->value) || empty($field->value['imagefile']))
{
	return;
}

$class = $fieldParams->get('image_class');

if ($class)
{
	$class = ' class="' . htmlentities($class, ENT_COMPAT, 'UTF-8', true) . '"';
}

$value  = $field->value;

if ($value)
{
	$img       = HTMLHelper::cleanImageURL($value['imagefile']);
	$imgUrl    = htmlentities($img->url, ENT_COMPAT, 'UTF-8', true);
	$alt       = empty($value['alt_text']) && empty($value['alt_empty']) ? '' : ' alt="' . htmlspecialchars($value['alt_text'], ENT_COMPAT, 'UTF-8') . '"';

	if ($img->attributes['width'] > 0 && $img->attributes['height'] > 0)
	{
		$buffer = sprintf('<img loading="lazy" width="%s" height="%s" src="%s"%s%s>',
			$img->attributes['width'],
			$img->attributes['height'],
			$imgUrl,
			$class,
			$alt
		);
	}
	else
	{
		$buffer = sprintf('<img src="%s"%s%s>',
			$imgUrl,
			$class,
			$alt
		);
	}

	echo $buffer;
}

The same content is in 21 releases, Joomla 4.0.4-rc1 to 4.1.0. See them all, or every version of this file.