WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] wp_get_attachment_image_src ignores size parameter [x-post] (2 posts)

  1. hootenanny1
    Member
    Posted 3 years ago #

    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));
    				}?>
  2. hootenanny1
    Member
    Posted 3 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic