Hi
I have a need to remove the link-to-image-node from an attached image in a page.
I have in my node.tpl.php:
print $node -> content['image_attach']['#value'];
print $node -> content['body']['#value'];
Is there someway to print $node -> content['image_attach']['#the_picture_without_link'] ??
Comments
Comment #1
trevor.eye9 commentedHello,
I just ran into this problem today. I searched and searched with no luck on finding what I needed. The "Hidden Link" option on this image settings did not work. I came up with a solution by using str_replace and ereg_replace.
Place the following anywhere you want to print your image. I used it in node.tpl.php.
Hope this helps.
Comment #2
UnicornSong commentedHey thanks for that. I cant even remember which project i was trying to do this on, but I'll file that code away in my snippet library for next time.
Comment #3
Marko B commentedgreat! thanx, wonder which API function adds this link over image?! as in theme_image there is no link?!
Comment #4
rainer_f commentedThere's also a longer discussion on #237275: Removing the href link from images that are in nodes. It would be fine to program a switch for this link into the admin interface of image.module.
Comment #5
drewish commentedComment #7
leo.ruffini commentedHi,
I had added the following code to node.tpl.php to remove the link-to-image-node from attached images and it has been working fine for months but not anymore. I guess something has changed in one of the Image module upgrades that makes the solution obsolete, but I'm not a developer myself, so I'm quite lost.
Any ideas?
Comment #8
joachim commentedPlease don't reopen age-old issues.
And secondly, whoever gave you that code, don't let them near your server again. Regexping html on the way to the browser is Bad Thing.
Comment #9
leo.ruffini commentedSorry about that. I thought it was better to reopen an issue than to create a duplicate.
Regarding the code, if you take a look you'll see it's quite simmilar to the one posted in comment #1 of this issue (and that was another reason to reopen it, since it doesn't work anymore).
Having said that, I need a way to remove the link-to-image-node. Is there a way to do do it? I can open a new issue if it's better.
Comment #10
joachim commentedOn second thoughts, as this is a support request rather than a bug, it's probably better to reopen rather than file a new one.
You need to get the latest dev of the module and override the theme function for attached images. You can simply change the bit that creates the link.
Comment #11
leo.ruffini commentedOK, so as you suggest, I reopen it.
From your answer, I understand I have to override the image_attach module itslef.
Is that the best solution? I'm asking because that would require to re-edit it every time I upgrade Image to a newer version... What about overriding this in templete.php?
Anyway, I'd appreciate if you could be more precise on the change I need to do on the code, since I know little php.... What lines do I need to change?
Thanks.
Comment #12
joachim commented> From your answer, I understand I have to override the image_attach module itslef.
No, override the theme function. Google it ;)
Comment #13
leo.ruffini commentedOK, I'll edit template.php. I know little php but I'll try. Any hint appreciated anyway.
Why do I need to use the latest dev instead of Beta , which I'm currently using?
Comment #14
joachim commented> Why do I need to use the latest dev instead of Beta , which I'm currently using?
I made big changes to the image attach theming functions recently, and there's not been a beta release since. The dev is perfectly stable.
> Any hint appreciated anyway.
I'm afraid I don't have time to give support with things like theming in this issue queue. Someone else reading this issue might (and I'll leave it open for a bit); or you can try the forum or IRC.
Comment #15
joachim commentedSeveral weeks since last post; closing.