I need to make some adjustments to


in Joomla 4.1.5.

For all (full) article images without an alt attribute the alt attribute should be the title of the article.

That works fine with adding the line

$item    = $displayData;

and replacing

'alt'      => empty($images->image_fulltext_alt) && empty($images->image_fulltext_alt_empty) ? false : $images->image_fulltext_alt,


'alt'      => $item->title,

Anyway, my challenge now is to only set the article title as an alt attribute in case I did not define an alt attribute in the article settings. I tried but I failed so far. But this should be an easy one, right?

1 Answer 1


I found a way to solve it:

if(empty($images->image_fulltext_alt) && empty($images->image_fulltext_alt_empty))
$alt = $item->title;
$alt = $images->image_fulltext_alt;


$layoutAttr = [
    'src'      => $images->image_fulltext,
    'itemprop' => 'image',
    'alt'      => $alt,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.