CoreFiles by mySites.guru
media.php47 lines, 1,036 bytes, from Joomla_4.0.0-beta6-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta5
md5
5ff2a70e71f07d2f381d8369a0b9b748
sha1
21deb99197fe8d26e1215925f8eb5d659c3dd8db
sha256
0961bae4d60b43cfa006c5aacb34abeeef21ffed673777c9ea3eb0ed7cb1dc38
<?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 ($field->value == '')
{
	return;
}

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

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

$value  = $field->value;

$buffer = '';

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 (file_exists($img->url))
	{
		$buffer .= sprintf('<img loading="lazy" width="%s" height="%s" src="%s"%s%s>',
			$img->attributes['width'],
			$img->attributes['height'],
			$imgUrl,
			$class,
			$alt
		);
	}
}

echo $buffer;

The same content is in 2 releases, Joomla 4.0.0-beta6 to 4.0.0-beta7. See them all, or every version of this file.