Support » Themes and Templates » How to? Attachment Image NOT link to file
10 years ago
I got my attachment.php template file going and it’s almost doing what I want, but how do I make the image NOT link to the file? I don’t at all want images outside my template.
It might be something to do with
php echo $attachment_link;
This is what I tried that didn’t work. First I switched to not using month-separated files for the images.
<img src="http://wwww.style-spotlight.net/wp-content/uploads/<?php echo basename($post->guid); ?>" alt="<?php echo basename($post->guid); ?>" />
Don’t know why it didn’t work!! 🙁
9 years, 11 months ago
I tried this and it worked.
-then open post-template.php
-at the bottom of the file is a section marked attachments
-you need to find the line
$innerHTML = get_attachment_innerHTML($_post->ID,
return "<a href='$url'> $innerHTML </a>";
-then take out the anchor after return so you have:
now you will be able to click on the thumbnail and have the full size image load into a page but not link to the actual file from the full size image.
*kinda sloppy I know, but it works.