How do stop image cropping in the Divi Gallery module?

, , ,

Recently in one of the DIVI related Facebook groups that I am a member of, one of the group wanted to know how to stop thumbnail images from being cropped in a Divi Gallery, so here’s what you need to do.

Add the the following code to the functions.php file of your child theme:


// Begin remove Divi Gallery Module image crop
function pa_gallery_image_width( $size ) {
return 9999;
}
function pa_gallery_image_height( $size ) {
return 9999;
}
add_filter( 'et_pb_gallery_image_width', 'pa_gallery_image_width' );
add_filter( 'et_pb_gallery_image_height', 'pa_gallery_image_height' );
// End remove Divi Gallery Module image crop

You should not add this code to the functions.php file of your main theme as every-time you update the theme you will have to remember re-add the code in, whereas with a child theme the theme code will be kept.

There is also code that you can use to stop blog featured images and portfolio featured images from being cropped and I will share these solutions in future blog posts.

Leave a comment

Why not discuss your project with us?