I’m wondering if it is possible to use different image sizes (medium, large) for the content on the homepage and single post pages. I have a narrow column on the homepage than on the single post pages and different image sizes would be nice.
Thanks.
I’m wondering if it is possible to use different image sizes (medium, large) for the content on the homepage and single post pages. I have a narrow column on the homepage than on the single post pages and different image sizes would be nice.
Thanks.
You must be logged in to post a comment.
If your talking about the images that are written into $post->post_content (the_content()) you’ll either need to write a filter that strips out all images and replaces them with the smaller version. Or you could just use CSS. For CSS make sure you have body_class() in your body tag then you can localise a maxwidth to your home page.
If you’re using the
body_class()
template tag, you can modify content-image max-width using CSS. For example:See the Template Hierarchy and
body_class()
Codex entries for more CSS class information.If you are using featured images you could use the following inside your loop.
Where
medium
is the image size you want to fetch.If you are using the attached images you could use the following functions.
The first one gives you the img tag while the second one gives you an array containing image source, width and height. You can use this function if you know the id of the attachment.
To create extra image sizes when you upload an image you can use the
add_image_size( 'custom', 210, 210, true );
function and then call the sizecustom
instead of the other sizes ( thumbnail, medium, large, full ). This function automatically creates an extra image with the dimensions specified ( if the dimension of the image are bigger than the specified dimensions ) when you upload an image through the media library.Now since you have already uploaded your images you would need to use the regenerate thumbanils plugin to generate the newly added image sizes.