When using the text filter module, if the title attribute is left empty, the caption shows " width= which seems to indicate the regular expression which checks for the pretense of the title attribute is failing somehow. I changed line 108 in the image_caption_filter.module and it seemed to fix the problem. Honestly, the current code seems fine to me since + checks for 1 or more characters which I would assume is what we want. Sometimes RexEx is weird I guess. :o/
Line 108 in image_caption_filter.module
$has_title = preg_match('/title=\"(.+?)\"/i', $img_tag, $matches) > 0;
to
$has_title = preg_match('/title=\"(.*?)\"/i', $img_tag, $matches) > 0;
Comments
Comment #1
jrstmartin commentedOMG THANK YOU! I lost some hair over that one! Same problem on 6.x-2.5. This is kind of a major issue assuming not everyone is going to put a caption on every image.
Comment #2
joglin commentedSubscribe.
Try it with
I suggest
is more fast.
Even others regex have the same bug
Comment #3
davidneedhamI can confirm this fix works. I rolled these proposed changed into a patch for review.
Comment #4
davidneedhamOops, made a mistake in the original patch. Here's a fixed version.
Comment #5
davidneedhamThe previous patch included a lot of whitespace fixes that my code editor automatically removed. Here's a new patch that only touches the fix and not the whitespacing.