• thegriffon

    (@thegriffon)


    Worked out how to use the [gallery] command with uploaded images, and modified image.php to display how I like, however I still have some unresolved issues:

    wp_get_attachment_image is set to ‘medium’, not full size as described
    the default (no argument) seems to set the main image to thumbnail size, not full size. seting the argument to ‘full’, calls the original image, but doesn’t display it full size.

    What are the arguments for wp_get_attachment_image, and how do I get the full size image to display without linking to it?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Bump – I’m having the same problem. I’d like to be able to display the full size image.

    WordPress is displaying the full size image and using HTML to scale it down to a box 500px wide by (something)px tall.

    $portimg = wp_get_attachment_image( $post->ID, 'full' );
    echo preg_replace('#(width|height)="\d+"#','',$portimg);

    The snippet above strips the WIDTH and HEIGHT attributes from the IMG tag that wp_get_attachment_image() outputs, and displays the image in its natural size. Not my preferred solution, but it works.

    Optimiza

    (@malditoweekend)

    Guys I have sort of the same problem but in my case I can´t display the medium size image, I just can controll and display the small thumbnail and large, I can´t find the right code to display the medium size thumb in single.php

    I use this code to display the thumb:

    <?php
    $files = get_children("post_parent=$id&post_type=attachment&post_mime_type=image");
    if($files){
            $keys = array_keys($files);
            $num=$keys[0];
    		$thumb=wp_get_attachment_thumb_url($num);
            print "<div class='tmb'><a href='".get_permalink()."' title=''><img src='$thumb' class='thumbnail' width='130' height='130' alt='' /></a></div>";
    }
    ?>

    And I use this to display the smaller thumb;

    <?php
    $files = get_children("post_parent=$id&post_type=attachment&post_mime_type=image");
    if($files){
            $keys = array_keys($files);
            $num=$keys[0];
            $thumb=wp_get_attachment_thumb_url($num);
            print "<a href='".get_permalink()."' title=''><img src='$thumb' class='thumbnail' width='50' height='50' alt='' /></a>";
    }
    ?>

    But when I try to use the medium size thumb WP resizes the thumb and doesn´t grab the medium size thumb he created it.

    Any advice?
    Real examples:
    Image 1
    Imaeg 2

    Optimiza

    (@malditoweekend)

    Solved! thanks anyway.

    malditoweekend how did you get the icon images on your site under quicknotes…

    also I am trying to get the images from the children/subpages pages that links back to the actual subpage… similar to ma.tt’s gallery
    any help… really appreciate it

    @malditoweekend:

    I’m trying to grab the medium version as well. Since this feature is still sparsely documented – the medium version is not mentioned in the function reference

    Would you post your solution for all of us?

    Thanks!
    Edde

    malditoweekend, i’m also looking to use the medium sized image in a similar way as you did. It’d be awesome if you could post your solution, as the documentation on this function is almost non-existent.

    Thanks!

    smart tip: do a multifilesearch on all php-files when wondering about a function.. lead me to create this example for you guys 😉

    $size = 150;
    $medium_image = wp_get_attachment_image_src($attachment->ID, array($size, $size), false);

    i haven’t checked but you might replace second value (the array) with “small”, “medium” etc. or just a single value..

    these three will do your work

    $att_img = wp_get_attachment_image($attachment->ID, array($size, $size), false); // gives <img src="...." />
    $att_src = wp_get_attachment_url($attachment->ID); // gives url to original size
    $att_src_thumb = wp_get_attachment_image_src($attachment->ID, array($size, $size), false); // gives url to givven size..

    I would still really like someone malditoweekend? to answer how to get the medium sized thumbnail on a page.

    zeniph

    (@zeniph)

    This returns an array of the path(s) to the medium sized image(s).
    Note that ‘medium’ can also be changed to thumbnail.

    <?php
    $images = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') ); ?>
    
    <?php foreach ($images as $imageId => $image): ?>
    	<?php
    	$wp_medium_image = wp_get_attachment_image_src($imageId,'medium', false);
    	?>
    <img src="<?php echo htmlentities($wp_medium_image[0]); ?>" />
Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘wp_get_attachment_image arguments’ is closed to new replies.