ALT attribute for thumbnails causes issues

Created on 19 December 2016, over 7 years ago
Updated 16 May 2024, about 1 month ago

As a result of the commit from the parent issue, slides with a blank alt attribute in the thumbnail navigation will not appear. This is because the regex looks for one or more characters in the alt attribute, and if it's empty then it thinks the rest of the img tag until the next set of quotes is the alt text, causing incorrect HTML to be displayed (or rather, not displayed).

Here's an example of the issue for the following images (first works, second doesn't):

<img src="[SNIP]/files/styles/flexslider_full/public/images/canopycreekautumn.jpg" alt="sdf" title="sdf">
$attributes['data-thumb-alt'] = sdf
HTML output: <li data-thumb="[SNIP]/files/styles/flexslider_full/public/images/canopycreekautumn.jpg" data-thumb-alt="sdf"><img src="[SNIP]/files/styles/flexslider_full/public/images/canopycreekautumn.jpg" width="800" height="500" alt="sdf" title="sdf" /></li>

<img src="[SNIP]/files/styles/flexslider_full/public/images/calm_0.jpg" alt="" title="">
$attributes['data-thumb-alt'] = " title=
HTML output: <li data-thumb="[SNIP]/files/styles/flexslider_full/public/images/calm_0.jpg" data-thumb-alt="&quot; title="><img src="[SNIP]/files/styles/flexslider_full/public/images/calm_0.jpg" width="800" height="500" alt="" title="" /></li>

The fix is to replace the + with an * in the alt regex.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.69.0 2024