Selecting more thatn <img> due to preg_match_all

Created on 5 November 2014, about 10 years ago
Updated 19 September 2023, about 1 year ago

When there is more that one within the code and the 1st does not have the attribute data-picture-mapping , the matching will select from the 1st to then end of the with the data-picture-mapping

When I patched the file picture.module to look like the below it worked (Note the [^>] just after img.

function _picture_filter_process($text, $filter) {

// Find all img tags with a data-picture-mapping attribute.
preg_match_all('/]*?data-picture-mapping=".*?>/i', $text, $images1);
preg_match_all('/]*?data-picture-group=".*?>/i', $text, $images2);

I also noted that if the source had upper case instead of
Then this also caused a problem.

So I changed picture.module as follows:

function _picture_filter_prepare_image($image) {
// Make sure the closing tag is right.
$image = str_replace('/>', '>', $image);
$image = str_replace('>', ' />', $image);
$image = str_replace('

🐛 Bug report
Status

Closed: outdated

Version

2.7

Component

Code

Created by

🇮🇪Ireland Chris_OConnor

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.

Production build 0.71.5 2024