BEFORE
AFTER
The Extra Theme limits the height of post images on the homepage (and elsewhere that post listings are displayed using the posts module) to 376px by default. Images taller than this will be cropped top and bottom, as shown in the before picture above.
If you’d like to prevent the images being cropped, you can increase the maximum height of the images to, say 1000px, by adding the following PHP code into Extra’s functions.php file, or into the functions.php file of a child theme (N.B. it’s advisable to take a backup of your site before editing PHP code as PHP errors can cause your site to become inaccessible):
// Prevent post listing image cropping // Change post module image max height function disable_cropping_on_medium_images() { add_image_size('extra-image-medium', 627, 1000, true); } add_action('after_setup_theme', 'disable_cropping_on_medium_images', 11);
If you wish to allow even taller images, simply increase the “1000” in the above.
Important: The fix above will apply only to newly uploaded images. To apply it to existing images you must regenerate the thumbnails using a plugin such as Force Regenerate Thumbnails. Thanks to Jessica for pointing this out.
Hi, thanks for this great tip. I tried it on my extra theme and its not working…
I tried re-uploading featured images on posts. The image would sometimes be fine, and sometimes not. Also, Force regenerate thumbnails sliced the pictures back to the short version.
Is there anything you think I might be doing wrong?
Hi Nkechi,
I think the reason it wasn’t working for you is that you are using the “blog” module on the homepage, rather than the default “posts” module (on which I based that tip).
This seems to work for the blog module:
add_filter(‘et_pb_blog_image_height’, ‘set_blog_image_max_height’);
function set_blog_image_max_height($height) { return 2000; }
As with the tip in the post, you need to add the PHP code into Extra’s functions.php file, or into the functions.php file of a child theme (N.B. it’s advisable to take a backup of your site before editing PHP code as PHP errors can cause your site to become inaccessible).
I don’t think you’ll need to run Force Regenerate Thumbnails – it should just work. Also, I haven’t quite figured out why some images worked for you and some didn’t, but hopefully this code will fix those that didn’t.
Let me know if it doesn’t work for you.
I had an issue with the thumbnails on the posts, they were cropped in half. The code didn’t work for me, but the thumbnail regenerator did. Thanks.
Great, glad that worked, Hayley! It was probably the combination of the code and the regeneration that did it. The code just informs WordPress of the size to use for the thumbnails, but this size isn’t actually applied until an image is either regenerated or fresly uploaded. Thanks!