Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress From Bootstrap to WordPress Create Bootstrap Styled Theme Templates Creating a Portfolio Landing Page

Images with auto resize?

Works with any image size?Because when i usea an image with different size the portflio post not showing the thumbs correctly.

3 Answers

Hi Gonzalo,

It may be worth looking into the add_image_size() function. This can be declared in the functions.php as seen below.


  add_image_size( '$name_of_image_size', $width, $height, $crop_to_size = false );

  // For your example
  add_image_size( 'large_thumbnail', 250, 250, false );


Then you can use that image size in your template with different functions. If you are inside the loop you can use the following.


  the_post_thumbnail_url( 'large_thumbnail' );


If you are outside the loop try using your previous method with the new defined size.

Hope this helps. Crsig

Thanks Craig.


Can you explain a little more about what you require help with please Gonzalo.


Yes. Im really sorry. I'm triyng to use wp_get_attachment_image_src function but when i use $size with values (ex: width 250, height 250) the function dont resize the image.

I have this code:

            $thumbnail_id = get_post_thumbnail_id(); 
            $size = array('width'=>250,'height'=>250);
            $thumbnail_url = wp_get_attachment_image_src( $thumbnail_id, $size, true );