How to? Attachment Image NOT link to file (3 posts)

  1. ColourDreamer
    Posted 9 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;


  2. ColourDreamer
    Posted 9 years ago #

    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!! :-(

  3. mikenstein
    Posted 9 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic