0

When I use wp_get_attachment_image_src(), the medium sized image is returned on 3 out of 6 of my images. The other 3, the full size image is returned. I've checked and the medium sized image exists for all of the images, even the ones where the full size image is only being returned. The only thing I can think of is that the images that will only return as full size, were very large when uploaded.

Here's my code:

$photos = get_post_custom( $photo_id );
for ( $i = 0; $i <= 12; $i++ ) { 
   if ( isset( $photos[ 'photo'.$i ][0] ) ) {
        $image_attributes = $alt = '';
        $image_attributes = wp_get_attachment_image_src( $photos['photo'.$i][0],  'medium' );
        $photo .= '<a href="'.wp_get_attachment_url( $photos['photo'.$i][0]).'" rel="lightbox-'.$i.'"><img src="'.$image_attributes[0].'" class="aligncenter size-full wp-image-'.$photos[ 'photo'.$i ][0].' lightbox-img" /></a>';
    }
}
  • Could you elaborate on your images sizes, etc? It is impossible to guess what might be going wrong from information you provided so far. – Rarst Feb 17 '14 at 23:02
  • $pic = wp_get_attachment_image_src( $picture['profile_pic'][0], 'coach-profile-pic' ); This sometimes returns a 'coach-profile-pic' sized image, sometimes it returns the full size image – Tom May 6 '14 at 14:32
  • The smaller images exist on the server...they're just not being returned – Tom May 7 '14 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.