Support » Themes and Templates » How to? Attachment Image NOT link to file

  • 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;


Viewing 2 replies - 1 through 2 (of 2 total)
  • This is what I tried that didn’t work. First I switched to not using month-separated files for the images.

    <img src="<?php echo basename($post->guid); ?>" alt="<?php echo basename($post->guid); ?>" />

    Don’t know why it didn’t work!! 🙁

    I tried this and it worked.

      -go to wp includes folder

      -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,
      $fullsize, $max_dims);
      	return "<a href='$url'> $innerHTML </a>";

      -then take out the anchor after return so you have:

      return "$innerHTML";

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to? Attachment Image NOT link to file’ is closed to new replies.