Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If the description, title and alt fields for an image are all empty, the alt tag will also be empty. I wanted to use the node title as the alt tag in this situation, so I did this:
In lightbox2.formatter.inc line 152, after:
// Set up the title.
$image_title = $item_data['description'];
$image_title = (!empty($image_title) ? $image_title : $item_data['title']);
$image_title = (!empty($image_title) ? $image_title : $item_data['alt']);
Added:
// Use node title as alt tag if description, title and alt fields are empty
$node = node_load($node->nid);
$image_title = (!empty($image_title) ? $image_title : $node->title);
Now, if description, title and alt are empty, the node title will be set as the alt tag.
It would be great to have this as an option under the Lightbox settings, and also perhaps add a number after the alt tag, so that they are somewhat different. What do you think?
Comments
Comment #1
stella CreditAttribution: stella commentedCommitted.
Comment #2
ressa CreditAttribution: ressa commentedGreat, thanks!