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.
I use a link with a picture inside in one of my static pages. But this module do not parse it correct and shows the img-tag in the block. :(
Would be OK if it searches for alt or better title attribute or use the html code.
PS: Sorry for my bad english...
Comments
Comment #1
csc4 CreditAttribution: csc4 commentedThis is actually a 4.7x and 5.x issue
Are there any regex guru's out there who could offer some help? I'm seeing this a lot as I use the amazontools module and the links from the images are horrible:
<h2>Links from Article Text</h2><ul><li><a nicetitle="Matched text: <a href="http://www.amazon.co.uk/gp/redirect.html%3FASIN=0743275284%26tag=googletag%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/o/ASIN/0743275284%253FSubscriptionId=1XFK01HK9NZWGPENWGG2" target="_blank"><img src="http://ec1.images-amazon.com/images/P/0743275284.01._SCTHUMBZZZ_.jpg" height="75" width="50" alt="cover of The Writing on the Wall: Why We Must Embrace China as a Partner or Face It as an Enemy" /></a>" href="http://www.amazon.co.uk/gp/redirect.html%3FASIN=0743275284%26tag=googletag%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/o/ASIN/0743275284%253FSubscriptionId=1XFK01HK9NZWGPENWGG2"><img src="http://ec1.images-amazon.com/images/P/0743275284.01._SCTHUMBZZZ_.jpg" height="75" width="50" alt="cover of The Writing on the Wall: Why We Must Embrace China as a Partner or Face It as an Enemy" /></a></li><li><a nicetitle="Matched text: <a href="http://www.amazon.co.uk/gp/redirect.html%3FASIN=0743275284%26tag=googletag%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/o/ASIN/0743275284%253FSubscriptionId=1XFK01HK9NZWGPENWGG2" target="_blank">The Writing on the Wall: Why We Must Embrace China as a Partner or Face It as an Enemy<br></a>" href="http://www.amazon.co.uk/gp/redirect.html%3FASIN=0743275284%26tag=googletag%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/o/ASIN/0743275284%253FSubscriptionId=1XFK01HK9NZWGPENWGG2">The Writing on the Wall: Why We Must Embrace China as a Partner or Face It as an Enemy<br></a></li></ul></div>
The original source it is parsing looks like
I found http://drupal.org/node/53880#comment-101916 which suggested
$output = preg_replace('#<a href="/\?q=glossary[^"]+" title="[^"]+"><img src="/[^"]+" /></a>#', '', $output );
to strip out glossary image links but I'm not sure how to get this changed to strip the img tags from Related Links? I've tried some things myself but I just don't seem to be getting anywhere.
I believe the issues is around line 103
I tried
but I don't seem to be getting anywhere.
Anyone out there good at regex?
Comment #2
csc4 CreditAttribution: csc4 commentedIs there really noone out there who can help with this regex?
Comment #3
smscotten CreditAttribution: smscotten commentedI took this from the 6.x code, which inherited this same problem. Any time there's a linked image the recommended links block contains HTML code for the image—very ugly behavior. My scorched-earth solution is simply to eliminate all links that contain HTML:
which changes
to
It's a bit extreme—it will exclude links that contain bolded or italic text, but it's a working solution for me. Ideally I guess we'd want something that takes the alt attribute of the image tag and makes a text link out of an image, but for my purposes, this is enough.
Hope that helps.
Comment #4
Zen CreditAttribution: Zen commentedI've committed a patch which strips tags from the text. While ideally, we would be looking at the anchor tag or img tag's title or alt attributes, this should do for the time being.
-K
Comment #6
smscotten CreditAttribution: smscotten commentedMight this modification eventually find its way into the beta or release version?
Comment #7
smscotten CreditAttribution: smscotten commentedZen, would you be so kind as to post the patch and/or other changes you made to fix this in 6.x-1.x-dev? I'd like to be able to change the behavior on a 7.x site.
Thanks!