PHP
Joomla! 6
Joomla! 5
Joomla! 4
Template Override
Basic
Strip #joomlaImage:// Metadata and Read Image Dimensions
Decodes article images JSON and extracts the clean URL plus intrinsic width and height with HTMLHelper::cleanImageURL() to prevent CLS.
templates/seu_template/html/com_content/article/default.php
<?php
declare(strict_types=1);
use Joomla\CMS\HTML\HTMLHelper;
$images = json_decode((string) ($this->item->images ?? '{}'));
if (!empty($images->image_intro)) {
$img = HTMLHelper::cleanImageURL($images->image_intro);
$src = $img->url;
$width = (int) ($img->attributes['width'] ?? 0);
$height = (int) ($img->attributes['height'] ?? 0);
$alt = (string) ($images->image_intro_alt ?: $this->item->title);
}
Extracts $img->url along with width and height attributes cleanly.
Technical explanation and best practices
Since Joomla 4, Media Manager appends metadata fragments like #joomlaImage://local-images/photo.jpg?width=1200&height=630. Calling HTMLHelper::cleanImageURL() gives you the clean URL and intrinsic dimensions for zero-CLS <img> tags.