Skip to content
Merged
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
08cd724
Fix images
dgrammatiko Oct 7, 2021
7fd6a59
menus
dgrammatiko Oct 7, 2021
f2bfbad
Update components/com_contact/tmpl/category/default_items.php
dgrammatiko Oct 8, 2021
ce2e00f
more
dgrammatiko Oct 8, 2021
e10da79
one more
dgrammatiko Oct 8, 2021
45ec5c4
more
dgrammatiko Oct 8, 2021
dc10268
Update components/com_contact/tmpl/contact/default.php
dgrammatiko Oct 8, 2021
7962abb
Update components/com_content/tmpl/category/blog.php
dgrammatiko Oct 8, 2021
c8132ff
Update components/com_newsfeeds/tmpl/category/default.php
dgrammatiko Oct 8, 2021
9a0f4d7
Update components/com_newsfeeds/tmpl/newsfeed/default.php
dgrammatiko Oct 8, 2021
6657f4c
Update components/com_newsfeeds/tmpl/newsfeed/default.php
dgrammatiko Oct 8, 2021
60633dc
Update modules/mod_articles_news/tmpl/_item.php
dgrammatiko Oct 8, 2021
5d051b0
Update components/com_newsfeeds/tmpl/newsfeed/default.php
dgrammatiko Oct 9, 2021
9bed5fc
Undo menu changes, proper invocation of HTMLHelper
dgrammatiko Oct 10, 2021
ee4c197
one more
dgrammatiko Oct 10, 2021
8738949
Use a Layout
dgrammatiko Oct 23, 2021
9aae3cd
one more
dgrammatiko Oct 23, 2021
6810fad
Update components/com_contact/tmpl/contact/default.php
dgrammatiko Oct 23, 2021
707d717
Update components/com_contact/tmpl/contact/default.php
dgrammatiko Oct 23, 2021
47291e5
Update components/com_contact/tmpl/category/default_items.php
dgrammatiko Oct 30, 2021
9d43461
Update components/com_contact/tmpl/contact/default.php
dgrammatiko Oct 30, 2021
5348c56
Update components/com_content/tmpl/category/blog.php
dgrammatiko Oct 30, 2021
19d99ea
Update components/com_newsfeeds/tmpl/category/default.php
dgrammatiko Oct 30, 2021
dd36e11
Update components/com_newsfeeds/tmpl/newsfeed/default.php
dgrammatiko Oct 30, 2021
38e61c8
Update modules/mod_articles_news/tmpl/_item.php
dgrammatiko Oct 30, 2021
8efc2a2
Update components/com_newsfeeds/tmpl/newsfeed/default.php
dgrammatiko Oct 30, 2021
1c8d811
Update components/com_newsfeeds/tmpl/newsfeed/default.php
dgrammatiko Oct 30, 2021
d50b8b0
Simplify the layout/data/etc
dgrammatiko Nov 3, 2021
687d583
meh
dgrammatiko Nov 3, 2021
4c54bb5
Redo
dgrammatiko Nov 3, 2021
6f67b9f
Update image.php
dgrammatiko Nov 4, 2021
a2b71cb
Update layouts/joomla/html/image.php
dgrammatiko Nov 4, 2021
9061a45
Update image.php
dgrammatiko Nov 5, 2021
27d1bc4
Replace title with figure/figcaprion
dgrammatiko Nov 6, 2021
e95e9ee
Update image.php
dgrammatiko Nov 6, 2021
2557b33
Update modules/mod_articles_news/tmpl/_item.php
dgrammatiko Nov 6, 2021
885d9ec
One common jlayout for all images
dgrammatiko Dec 22, 2021
c5fa812
Meh
dgrammatiko Dec 22, 2021
1ce9cf4
oops
dgrammatiko Dec 22, 2021
bcaa805
Remove double escaping
dgrammatiko Dec 23, 2021
a32c810
Remove double escaping
dgrammatiko Dec 23, 2021
6a1dcc6
simplify, the loading part, revert some CS
dgrammatiko Dec 25, 2021
7f2f4fc
Remove unused imports
dgrammatiko Dec 25, 2021
0990be1
use escape in the jLayouts
dgrammatiko Dec 25, 2021
fbbb8cc
Update components/com_content/tmpl/category/blog.php
dgrammatiko Dec 25, 2021
ba3250b
Update components/com_content/tmpl/category/blog.php
dgrammatiko Dec 25, 2021
b976276
Update components/com_newsfeeds/tmpl/newsfeed/default.php
dgrammatiko Dec 25, 2021
1877d55
Update layouts/joomla/html/image.php
dgrammatiko Dec 25, 2021
282fa98
Update modules/mod_articles_news/tmpl/_item.php
dgrammatiko Dec 25, 2021
bf34ca0
Update layouts/joomla/html/image.php
dgrammatiko Dec 26, 2021
4fd81ee
Update components/com_contact/tmpl/category/default_items.php
dgrammatiko Dec 26, 2021
7f312c1
Update layouts/joomla/content/intro_image.php
dgrammatiko Dec 28, 2021
4b64a15
Update components/com_newsfeeds/tmpl/newsfeed/default.php
dgrammatiko Dec 28, 2021
9cc8b33
Update components/com_newsfeeds/tmpl/newsfeed/default.php
dgrammatiko Dec 28, 2021
4865886
comment
dgrammatiko Dec 28, 2021
d0bbb00
the obj reurned from cleanImageURL has a url and attributes
dgrammatiko Dec 30, 2021
6fce942
Update layouts/joomla/html/image.php
dgrammatiko Dec 30, 2021
19ac361
Remove extra isset
dgrammatiko Dec 30, 2021
cad01eb
Update image.php
dgrammatiko Dec 30, 2021
020c806
meh
dgrammatiko Dec 30, 2021
6badaac
use escape
dgrammatiko Dec 30, 2021
bba0545
Update layouts/joomla/html/image.php
dgrammatiko Dec 30, 2021
a782b24
Add missing category image
dgrammatiko Dec 31, 2021
1ec83be
Respect the no Description checkbox
dgrammatiko Dec 31, 2021
d0ba9b8
DO NOT UNSET OBJECT PARTS!
dgrammatiko Dec 31, 2021
49c8ff6
Skip double escaping
dgrammatiko Dec 31, 2021
4d5ff42
CS
dgrammatiko Dec 31, 2021
8f4d6d2
Update components/com_newsfeeds/tmpl/newsfeed/default.php
dgrammatiko Dec 31, 2021
0da6cb4
Merge branch '4.0-dev' into 4.0-dev-images
dgrammatiko Jan 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion components/com_contact/tmpl/category/default_items.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\Component\Contact\Administrator\Helper\ContactHelper;
Expand Down Expand Up @@ -99,7 +100,14 @@ class="inputbox" onchange="document.adminForm.submit();"
<a href="<?php echo Route::_(RouteHelper::getContactRoute($item->slug, $item->catid, $item->language)); ?>">
<?php if ($this->params->get('show_image_heading')) : ?>
<?php if ($item->image) : ?>
<?php echo HTMLHelper::_('image', $item->image, '', array('class' => 'contact-thumbnail img-thumbnail')); ?>
<?php echo LayoutHelper::render(
'joomla.html.image',
[
'src' => $item->image,
'alt' => '',
'class' => 'contact-thumbnail img-thumbnail',
]
); ?>
<?php endif; ?>
<?php endif; ?>
<?php echo $this->escape($item->name); ?>
Expand Down
13 changes: 8 additions & 5 deletions components/com_contact/tmpl/contact/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Router\Route;
use Joomla\Component\Contact\Site\Helper\RouteHelper;
Expand Down Expand Up @@ -97,11 +98,13 @@

<?php if ($this->item->image && $tparams->get('show_image')) : ?>
<div class="com-contact__thumbnail thumbnail">
<?php echo HTMLHelper::_(
'image',
$this->item->image,
htmlspecialchars($this->item->name, ENT_QUOTES, 'UTF-8'),
array('itemprop' => 'image')
<?php echo LayoutHelper::render(
'joomla.html.image',
[
'src' => $this->item->image,
'alt' => $this->item->name,
'itemprop' => 'image',
]
); ?>
</div>
<?php endif; ?>
Expand Down
21 changes: 13 additions & 8 deletions components/com_content/tmpl/category/blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\Layout\LayoutHelper;

$app = Factory::getApplication();

Expand Down Expand Up @@ -54,8 +55,13 @@
<?php if ($beforeDisplayContent || $afterDisplayContent || $this->params->get('show_description', 1) || $this->params->def('show_description_image', 1)) : ?>
<div class="category-desc clearfix">
<?php if ($this->params->get('show_description_image') && $this->category->getParams()->get('image')) : ?>
<?php $alt = empty($this->category->getParams()->get('image_alt')) && empty($this->category->getParams()->get('image_alt_empty')) ? '' : 'alt="' . htmlspecialchars($this->category->getParams()->get('image_alt'), ENT_COMPAT, 'UTF-8') . '"'; ?>
<img src="<?php echo $this->category->getParams()->get('image'); ?>" <?php echo $alt; ?>>
<?php echo LayoutHelper::render(
'joomla.html.image',
[
'src' => $this->category->getParams()->get('image'),
'alt' => empty($this->category->getParams()->get('image_alt')) && empty($this->category->getParams()->get('image_alt_empty')) ? false : $this->category->getParams()->get('image_alt'),
]
); ?>
<?php endif; ?>
<?php echo $beforeDisplayContent; ?>
<?php if ($this->params->get('show_description') && $this->category->description) : ?>
Expand All @@ -75,12 +81,11 @@
<?php if (!empty($this->lead_items)) : ?>
<div class="com-content-category-blog__items blog-items items-leading <?php echo $this->params->get('blog_class_leading'); ?>">
<?php foreach ($this->lead_items as &$item) : ?>
<div class="com-content-category-blog__item blog-item"
itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
<?php
$this->item = & $item;
echo $this->loadTemplate('item');
?>
<div class="com-content-category-blog__item blog-item" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
<?php
$this->item = &$item;
echo $this->loadTemplate('item');
?>
</div>
<?php $leadingcount++; ?>
<?php endforeach; ?>
Expand Down
9 changes: 8 additions & 1 deletion components/com_newsfeeds/tmpl/category/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\Layout\LayoutHelper;

$pageClass = $this->params->get('pageclass_sfx');
$htag = $this->params->get('show_page_heading') ? 'h2' : 'h1';
Expand All @@ -34,7 +35,13 @@
<?php if ($this->params->get('show_description', 1) || $this->params->def('show_description_image', 1)) : ?>
<div class="com-newsfeeds-category__description category-desc">
<?php if ($this->params->get('show_description_image') && $this->category->getParams()->get('image')) : ?>
<img src="<?php echo $this->category->getParams()->get('image'); ?>">
<?php echo LayoutHelper::render(
'joomla.html.image',
[
'src' => $this->category->getParams()->get('image'),
'alt' => empty($this->category->getParams()->get('image_alt')) && empty($this->category->getParams()->get('image_alt_empty')) ? false : $this->category->getParams()->get('image_alt'),
]
); ?>
<?php endif; ?>
<?php if ($this->params->get('show_description') && $this->category->description) : ?>
<?php echo HTMLHelper::_('content.prepare', $this->category->description, '', 'com_newsfeeds.category'); ?>
Expand Down
56 changes: 35 additions & 21 deletions components/com_newsfeeds/tmpl/newsfeed/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\Layout\LayoutHelper;

?>

Expand Down Expand Up @@ -61,30 +62,37 @@
<!-- Show Images from Component -->
<?php if (isset($images->image_first) && !empty($images->image_first)) : ?>
<?php $imgfloat = empty($images->float_first) ? $this->params->get('float_first') : $images->float_first; ?>
<?php $alt = empty($images->image_first_alt) && empty($images->image_first_alt_empty)
? ''
: 'alt="' . htmlspecialchars($images->image_first_alt, ENT_COMPAT, 'UTF-8') . '"'; ?>

<div class="com-newsfeeds-newsfeed__first-image img-intro-<?php echo htmlspecialchars($imgfloat, ENT_COMPAT, 'UTF-8'); ?>">
<img
<?php if ($images->image_first_caption) : ?>
<?php echo 'class="caption" title="' . htmlspecialchars($images->image_first_caption, ENT_COMPAT, 'UTF-8') . '"'; ?>
<?php endif; ?>
src="<?php echo htmlspecialchars($images->image_first, ENT_COMPAT, 'UTF-8'); ?>" <?php echo $alt; ?>>
<div class="com-newsfeeds-newsfeed__first-image img-intro-<?php echo $this->escape($imgfloat); ?>">
<figure>
<?php echo LayoutHelper::render(
'joomla.html.image',
[
'src' => $images->image_first,
'alt' => empty($images->image_first_alt) && empty($images->image_first_alt_empty) ? '' : $images->image_first_alt,
]
); ?>
<?php if ($images->image_first_caption) : ?>
<figcaption class="caption"><?php echo $this->escape($images->image_first_caption); ?></figcaption>
<?php endif; ?>
</figure>
</div>
<?php endif; ?>

<?php if (isset($images->image_second) and !empty($images->image_second)) : ?>
<?php $imgfloat = empty($images->float_second) ? $this->params->get('float_second') : $images->float_second; ?>
<?php $alt = empty($images->image_second_alt) && empty($images->image_second_alt_empty)
? ''
: 'alt="' . htmlspecialchars($images->image_second_alt, ENT_COMPAT, 'UTF-8') . '"'; ?>
<div class="com-newsfeeds-newsfeed__second-image float-<?php echo htmlspecialchars($imgfloat, ENT_COMPAT, 'UTF-8'); ?> item-image">
<img
<?php if ($images->image_second_caption) : ?>
<?php echo 'class="caption" title="' . htmlspecialchars($images->image_second_caption) . '"'; ?>
<?php endif; ?>
src="<?php echo htmlspecialchars($images->image_second, ENT_COMPAT, 'UTF-8'); ?>" <?php echo $alt; ?>>
<div class="com-newsfeeds-newsfeed__second-image float-<?php echo $this->escape($imgfloat); ?> item-image">
<figure>
<?php echo LayoutHelper::render(
'joomla.html.image',
[
'src' => $images->image_second,
'alt' => empty($images->image_second_alt) && empty($images->image_second_alt_empty) ? false : $images->image_second_alt,
]
); ?>
<?php if ($images->image_second_caption) : ?>
<figcaption class="caption"><?php echo $this->escape($images->image_second_caption); ?></figcaption>
<?php endif; ?>
</figure>
</div>
<?php endif; ?>
<!-- Show Description from Component -->
Expand All @@ -98,9 +106,15 @@
<?php endif; ?>

<!-- Show Image -->
<?php if ($this->rssDoc->image && $this->params->get('show_feed_image')) : ?>
<?php if ($this->rssDoc->image && $this->params->get('show_feed_image')) : ?>
<div class="com-newsfeeds-newsfeed__feed-image">
<img src="<?php echo $this->rssDoc->image->uri; ?>" alt="<?php echo $this->rssDoc->image->title; ?>" />
<?php echo LayoutHelper::render(
'joomla.html.image',
[
'src' => $this->rssDoc->image->uri,
'alt' => $this->rssDoc->image->title,
]
); ?>
</div>
<?php endif; ?>

Expand Down
10 changes: 7 additions & 3 deletions layouts/joomla/content/category_default.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@
<?php if ($beforeDisplayContent || $afterDisplayContent || $params->get('show_description', 1) || $params->def('show_description_image', 1)) : ?>
<div class="category-desc">
<?php if ($params->get('show_description_image') && $category->getParams()->get('image')) : ?>
<?php $alt = empty($category->getParams()->get('image_alt')) && empty($category->getParams()->get('image_alt_empty')) ? '' : 'alt="' . htmlspecialchars($category->getParams()->get('image_alt'), ENT_COMPAT, 'UTF-8') . '"'; ?>
<img src="<?php echo $category->getParams()->get('image'); ?>" <?php echo $alt; ?>>
<?php echo LayoutHelper::render(
'joomla.html.image',
[
'src' => $category->getParams()->get('image'),
'alt' => empty($category->getParams()->get('image_alt')) && empty($category->getParams()->get('image_alt_empty')) ? false : $category->getParams()->get('image_alt'),
]
); ?>
<?php endif; ?>
<?php echo $beforeDisplayContent; ?>
<?php if ($params->get('show_description') && $category->description) : ?>
Expand All @@ -97,4 +102,3 @@
<?php endif; ?>
</div>
</div>

30 changes: 10 additions & 20 deletions layouts/joomla/content/full_image.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\Layout\LayoutHelper;

$params = $displayData->params;
$images = json_decode($displayData->images);
Expand All @@ -20,25 +19,16 @@
return;
}

$imgclass = empty($images->float_fulltext) ? $params->get('float_fulltext') : $images->float_fulltext;
$extraAttr = '';
$img = HTMLHelper::cleanImageURL($images->image_fulltext);
$alt = empty($images->image_fulltext_alt) && empty($images->image_fulltext_alt_empty) ? '' : 'alt="' . htmlspecialchars($images->image_fulltext_alt, ENT_COMPAT, 'UTF-8') . '"';

// Set lazyloading only for images which have width and height attributes
if ((isset($img->attributes['width']) && (int) $img->attributes['width'] > 0)
&& (isset($img->attributes['height']) && (int) $img->attributes['height'] > 0))
{
$extraAttr = ArrayHelper::toString($img->attributes) . ' loading="lazy"';
}
$imgclass = empty($images->float_fulltext) ? $params->get('float_fulltext') : $images->float_fulltext;
$layoutAttr = [
'src' => $images->image_fulltext,
'itemprop' => 'image',
'alt' => empty($images->image_fulltext_alt) && empty($images->image_fulltext_alt_empty) ? false : $images->image_fulltext_alt,
];
?>
<figure class="<?php echo htmlspecialchars($imgclass, ENT_COMPAT, 'UTF-8'); ?> item-image">
<img src="<?php echo htmlspecialchars($img->url, ENT_COMPAT, 'UTF-8'); ?>"
<?php echo $alt; ?>
itemprop="image"
<?php echo $extraAttr; ?>
/>
<figure class="<?php echo $this->escape($imgclass); ?> item-image">
<?php echo LayoutHelper::render('joomla.html.image', $layoutAttr); ?>
<?php if ($images->image_fulltext_caption !== '') : ?>
<figcaption class="caption"><?php echo htmlspecialchars($images->image_fulltext_caption, ENT_COMPAT, 'UTF-8'); ?></figcaption>
<figcaption class="caption"><?php echo $this->escape($images->image_fulltext_caption); ?></figcaption>
<?php endif; ?>
</figure>
38 changes: 11 additions & 27 deletions layouts/joomla/content/intro_image.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@

defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;
use Joomla\Component\Content\Site\Helper\RouteHelper;
use Joomla\Utilities\ArrayHelper;

$params = $displayData->params;
$images = json_decode($displayData->images);
Expand All @@ -22,36 +21,21 @@
return;
}

$imgclass = empty($images->float_intro) ? $params->get('float_intro') : $images->float_intro;
$extraAttr = '';
$img = HTMLHelper::cleanImageURL($images->image_intro);
$alt = empty($images->image_intro_alt) && empty($images->image_intro_alt_empty) ? '' : 'alt="' . htmlspecialchars($images->image_intro_alt, ENT_COMPAT, 'UTF-8') . '"';

// Set lazyloading only for images which have width and height attributes
if ((isset($img->attributes['width']) && (int) $img->attributes['width'] > 0)
&& (isset($img->attributes['height']) && (int) $img->attributes['height'] > 0))
{
$extraAttr = ArrayHelper::toString($img->attributes) . ' loading="lazy"';
}
$imgclass = empty($images->float_intro) ? $params->get('float_intro') : $images->float_intro;
$layoutAttr = [
'src' => $images->image_intro,
'alt' => empty($images->image_intro_alt) && empty($images->image_intro_alt_empty) ? false : $images->image_intro_alt,
];
?>
<figure class="<?php echo htmlspecialchars($imgclass, ENT_COMPAT, 'UTF-8'); ?> item-image">
<figure class="<?php echo $this->escape($imgclass); ?> item-image">
<?php if ($params->get('link_intro_image') && ($params->get('access-view') || $params->get('show_noauth', '0') == '1')) : ?>
<a href="<?php echo Route::_(RouteHelper::getArticleRoute($displayData->slug, $displayData->catid, $displayData->language)); ?>"
itemprop="url" title="<?php echo $this->escape($displayData->title); ?>">
<img src="<?php echo htmlspecialchars($img->url, ENT_COMPAT, 'UTF-8'); ?>"
<?php echo $alt; ?>
itemprop="thumbnailUrl"
<?php echo $extraAttr; ?>
/>
<a href="<?php echo Route::_(RouteHelper::getArticleRoute($displayData->slug, $displayData->catid, $displayData->language)); ?>" itemprop="url" title="<?php echo $this->escape($displayData->title); ?>">
<?php echo LayoutHelper::render('joomla.html.image', array_merge($layoutAttr, ['itemprop' => 'thumbnailUrl'])); ?>
</a>
<?php else : ?>
<img src="<?php echo htmlspecialchars($img->url, ENT_COMPAT, 'UTF-8'); ?>"
<?php echo $alt; ?>
itemprop="thumbnail"
<?php echo $extraAttr; ?>
/>
<?php echo LayoutHelper::render('joomla.html.image', array_merge($layoutAttr, ['itemprop' => 'thumbnail'])); ?>
<?php endif; ?>
<?php if (isset($images->image_intro_caption) && $images->image_intro_caption !== '') : ?>
<figcaption class="caption"><?php echo htmlspecialchars($images->image_intro_caption, ENT_COMPAT, 'UTF-8'); ?></figcaption>
<figcaption class="caption"><?php echo $this->escape($images->image_intro_caption); ?></figcaption>
<?php endif; ?>
</figure>
49 changes: 49 additions & 0 deletions layouts/joomla/html/image.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

/**
* Layout variables
* -----------------
* @var array $displayData Array with all the given attributes for the image element.
* Eg: src, class, alt, width, height, loading, decoding, style, data-*
* Note: only the alt and src attributes are escaped by default!
*/
defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\Utilities\ArrayHelper;

$img = HTMLHelper::_('cleanImageURL', $displayData['src']);

$displayData['src'] = $this->escape($img->url);

if (isset($displayData['alt']))
{
if ($displayData['alt'] === false)
{
unset($displayData['alt']);
}
else
{
$displayData['alt'] = $this->escape($displayData['alt']);
}
}

if ($img->attributes['width'] > 0 && $img->attributes['height'] > 0)
{
$displayData['width'] = $img->attributes['width'];
$displayData['height'] = $img->attributes['height'];

if (empty($displayData['loading']))
{
$displayData['loading'] = 'lazy';
}
}

echo '<img ' . ArrayHelper::toString($displayData) . '>';
8 changes: 0 additions & 8 deletions libraries/src/HTML/HTMLHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -707,19 +707,11 @@ public static function cleanImageURL($url)
{
$obj->attributes['width'] = $width;
}
else
{
unset($obj->attributes['width']);
}

if ($height > 0)
{
$obj->attributes['height'] = $height;
}
else
{
unset($obj->attributes['height']);
}

$mediaUri->setFragment('');
$obj->url = $mediaUri->toString();
Expand Down
Loading