WordPress.org

Ready to get started?Download WordPress

Forums

Help Getting Images to Display With Attachment.php (7 posts)

  1. Stocktrading101
    Member
    Posted 5 years ago #

    I just found out about and added attachment.php so that when I link an image to a page it uses the attachment.php template and displays the image in its full size.

    The problem I am having is that I can link images fine and when you click them it pulls the attachment.php template fine, but the image is missing!

    Is there a simple call function to pull up the image that I am missing? My current template is very simple,

    "
    <p>test text</p>

    <?php the_content(); ?>
    "

    What am I missing here?

  2. Evita
    Member
    Posted 5 years ago #

    Try <?php echo $attachment_link ?>

  3. Stocktrading101
    Member
    Posted 5 years ago #

    No luck :(

    Any other ideas? I even tried copying my whole index.php but that didn't work either. There has to be a tag that I am missing that displays the full image.

  4. Stocktrading101
    Member
    Posted 5 years ago #

    Ok found coding via google search to make the image atleast appear and fairly large just not full size and I think if I tweak this it will work just dont know what to tweak,

    <?php $attachment_link = get_the_attachment_link($post->ID, true, array(450, 800)); // This also populates the iconsize for the next line ?>
    <?php $_post = &get_post($post->ID); $classname = ($_post->iconsize[0] <= 128 ? 'small' : '') . 'attachment'; // This lets us style narrow icons specially ?>

    Thoughts?

  5. Stocktrading101
    Member
    Posted 5 years ago #

    GOT IT TO DISPLAY FULL SIZE

    Only problem is the image is still a LINK to the original image location,

    <?php $attachment_link = get_the_attachment_link($post->ID, true, array()); // This also populates the iconsize for the next line ?>
    <?php echo $attachment_link; ?>

    How do I edit this so the image appears but is not a link? Thanks in advance.

  6. Stocktrading101
    Member
    Posted 5 years ago #

    RIGHT well I now figured out how to get the image to display without being linked, but for the life of me I can't them to display in their full size!!

    You would think,

    <?php echo wp_get_attachment_image( $post->ID, 'full' ); ?>

    would work but for some reason the images max out width wise at 500 pixels! If you put 'medium' in it works fine with the images medium and 'full' or '100%' works fine for SMALL images but again anything over 500 pixels wide is shrunk to this max.

    I am burnt out, please if anyone can step in and help it would immensely appreciated....

  7. Evita
    Member
    Posted 5 years ago #

    I am sorry, I forgot this piece of code.
    After
    <?php get_header(); ?>
    put

    <?php the_post() ?>
    <?php $attachment_link = get_the_attachment_link($post->ID, true, array(450, 800)); // YOUR WIDTH HEIGHT ?>
    <?php $_post = &get_post($post->ID); $classname = ($_post->iconsize[0] <= 150 ? 'small' : '') . 'attachment'; // GIVES SMALL ITEMS A 'SMALL' CLASS ?>

    and into your entry-div
    <?php echo $attachment_link ?>

Topic Closed

This topic has been closed to new replies.

About this Topic