Support » Themes and Templates » [Resolved] wp_get_attachment_image_src ignores size parameter [x-post]

[Resolved] wp_get_attachment_image_src ignores size parameter [x-post]

  • Hi, I’ve already posted the following in “how to & troubleshooting” two weeks ago but haven’t gotten any replies. After reading through the forums a bit, I’ve come to the conclusion that I picked the wrong subforum and I hope people can help me here. Thanks a lot, so here we go:

    I’m using wp_get_attachment_image_src to display images that I’ve uploaded and attached to the current post using the media section of the wp-admin backend.

    According to the Codex for the size parameter I can provide an array with width and height, however the function does not create an image with these parameters, but rather selects which ever one of the standard sizes (thumb, medium, large, full) fits my dimensions the closest.

    Can anyone help? Thanks a lot.

    Here’s the code I’m using within the loop:

    <?php $images =& get_children( 'post_type=attachment&post_mime_type=image&numberposts=1&post_parent='.get_the_id() );
    				foreach( $images as $image => $image_object) {
    					$image_full = wp_get_attachment_image_src($image_object->ID, array( 569, 10));
    					$image_thumb = wp_get_attachment_image_src($image_object->ID, array( 71, 40));
Viewing 1 replies (of 1 total)
  • After a lot of Googling I finally managed to find a solution by myself, so in case anyone wonders how I did it:

    I’ve used the function add_image_size($name,$width,$height,$crop) which has to be used in the functions.php according to the function reference for add_image_size.

    Then I installed the plugin Regenerate Thumbnails which checks for additional thumbnail sizes you have specified (in the functions.php) and generates thumbs for those.

    I hope I can help the next guy to have this problem, have a nice day!

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] wp_get_attachment_image_src ignores size parameter [x-post]’ is closed to new replies.