Following on from the recent blog post about how to prevent images from cropping within the DIVI gallery module, here’s how to do it within the portfolio and filterable portfolio modules.
You need to add the the following code to the functions.php file of your child theme:
// Begin remove Divi Portfolio and Filterable Portfolio featured image crop
function pa_portfolio_image_width($width) {
return '9999';
}
function pa_portfolio_image_height($height) {
return '9999';
}
add_filter( 'et_pb_portfolio_image_width', 'pa_portfolio_image_width' );
add_filter( 'et_pb_portfolio_image_height', 'pa_portfolio_image_height' );
// End remove Divi Portfolio and Filterable Portfolio featured 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.
Thank you, thank you, thank you! I’ve tried so many versions of css which still cropped the image. This was the only answer!
Thanks for getting in touch.
Glad to hear that this css code helped solve the issues you were encountering with your website.