No Code Attached Yet
avatar Scrabble96
Scrabble96
11 Feb 2022

Steps to reproduce the issue

  1. Add an image to an article via the Images and Links tab
  2. Create a custom field of type Media then add an image via that field to an article
  3. Inspect the result on the front end

Expected result

There should be 'height' and 'width' attributes as well as loading="lazy"

Actual result

There are no 'height' and 'width' attributes or loading="lazy"

System information (as much as possible)

J4.0.6

Additional comments

In the /plugins/fields/media/tmpl/media.php file lines 33 to 50 are:

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
		);
	}

with line 35 looking for width and height. But it's obviously not picking those attributes up. Why? If an image is added to an article in the editor, all three attributes are added, so the data is obviously available.

avatar Scrabble96 Scrabble96 - open - 11 Feb 2022
avatar joomla-cms-bot joomla-cms-bot - change - 11 Feb 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 11 Feb 2022
avatar dgrammatiko
dgrammatiko - comment - 11 Feb 2022

Please test #37008

avatar Quy Quy - change - 11 Feb 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-02-11 19:04:53
Closed_By Quy
avatar Quy Quy - close - 11 Feb 2022

Add a Comment

Login with GitHub to post a comment