How to override /layouts/joomla/html/image.php layout file? Topic is solved

Everything to do with Joomla! 3.x templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
Abatap
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Thu Aug 31, 2017 1:49 pm

How to override /layouts/joomla/html/image.php layout file?

Post by Abatap » Fri Oct 27, 2023 9:40 am

Hello. Is this possible to override the /layouts/joomla/html/image.php file? Or any other layout file from the /layouts/joomla/html/ directory?

I've tried to place my override code file to /templates/TEMPLATE/html/layouts/joomla/html/ and to /templates/TEMPLATE/html/ but had no luck in Joomla! picking that up and instead it goes on with its stock image layout.

The funny thing is, when I include the image layout directly with something like the code snippet below then my override file gets properly included instead of the stock layout:

Code: Select all

<?php echo Joomla\CMS\Layout\LayoutHelper::render('joomla.html.image', array('src' => $itemImagePath, 'alt' => $itemImageAlt)); ?>
But if I try to render my image using the snippet below, it keeps using the stock layout:

Code: Select all

<?php echo Joomla\CMS\HTML\HTMLHelper::image($itemImagePath, $itemImageAlt); ?>
As for the official Joomla! documentation, it makes no mention of any exceptions to its layout overriding mechanism:
https://docs.joomla.org/J3.x:Layout_Overrides_in_Joomla

P.S. My Joomla! version is 3.10.12

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44096
Joined: Sat Apr 05, 2008 9:58 pm

Re: How to override /layouts/joomla/html/image.php layout file?

Post by Webdongle » Sat Oct 28, 2023 4:51 am

Check your editor settings for what code it allows
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2909
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: How to override /layouts/joomla/html/image.php layout file?

Post by SharkyKZ » Sat Oct 28, 2023 10:29 am

It's just another oversight related to image handling in J4. In J3 the image rendering was done through HTMLHelper::image(). Internally it did not use layouts. Then in J4 someone decided to render images directly through layouts. This dumb change was backported to J3. Then J4 switched back to using HTMLHelper::image() which now used layouts internally (this is fine). But this changed was never backported to J3.

Abatap
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Thu Aug 31, 2017 1:49 pm

Re: How to override /layouts/joomla/html/image.php layout file?

Post by Abatap » Tue Dec 12, 2023 11:10 am

I see. Thank you for a thorough explanation!


Post Reply

Return to “Templates for Joomla! 3.x”