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! While you're at it, check out some resources Treehouse students have shared here.

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 WordPress Theme Development Custom Post Type Templates in WordPress The Portfolio Single Page

Can image size be set in code?

When Zac needs to change the image size in the single portfolio page he goes in and edits the attributes of each image individually. It seems to me that it should be possible to specify the image size to use within the code? Is this possible, and if so how? The same issue also relates to setting the image URL - could this not be set in code also?

2 Answers

Also, WordPress has an add_image_size() function that you can use to when using images throughout your site. https://developer.wordpress.org/reference/functions/add_image_size/

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 Points

I believe you can go into the admin settings and set images to be a custom size. I can't remember from the top of my head precisely where but it should be somewhere in General settings.

For greater control of specific you should be able to go into a template file and specify image size attributes in there. Of give the image you want a class and change the CSS properties. All sorts of options. :-)