When 'add a link to the original image' is enabled, this link is always added on resized images even when an existing hyperlink is already spanning the image.
This turns
<a href="mylink"> <img src="image.png" width="200" /> </a>
into
<a href="mylink"> <a href="image.png"><img src="resize/image-200x200.png" width="200" /></a> </a></a>
Which is an HTML syntax error and causes the image to no longer lead to the 'mylink' URL.
The current workaround is either to disable 'link to original' altogether, or upload the affected image in the correct size so that image resize filter leaves it unaffected.
Comments
Comment #1
florisla commentedNote that my original description above contains a typo. The correct (i.e. typo-free) output reads like:
<a href="mylink"> <a href="image.png"><img src="resize/image-200x200.png" width="200" /></a> </a>I suspect a solution would involve some regex trickery to determine whether the
<img>lies in an opened<a>tag.Comment #2
mxmilkiib commentedsubscribe
Comment #3
quicksketchI've committed this patch which checks to see if the image is wrapped in an
<a>tag. Note that this still will not be perfect since there might be an anchor tag around not only the image but also other tags. For example the following would not be corrected:However such situations are rare compared with wrapping the image in a link directly. Whitespace is still allowed between the anchor and the img tag.