As you probably already know, its always best to create a child theme for your WordPress theme you are using to future proof your site from any updates that may be done on the theme by its developers.
Its easy to make most changes in a child theme but sometimes its difficult to think about how to move a change to a child theme. For instance, if you are using a theme from ElegantThemes, and you want to change a thumbnail image size in it, then you may find it difficult to do in a child theme. Here’s the procedure.
You can see all registered image sizes for a theme from ElegantThemes in post_thumbnails_themename.php. For example, if you are using the Divi WordPress theme, you can see all the registered images sizes for this theme in the file post_thumbnails_divi.php.
'400x250' => 'et-pb-post-main-image',
'1080x675' => 'et-pb-post-main-image-fullwidth',
'400x284' => 'et-pb-portfolio-image',
'1080x9999' => 'et-pb-portfolio-image-single',
);
Now, to change one of these image sizes in child theme, first filter the image sizes array to remove the specific size and then add a new one with the same name. You need to make this change in the functions.php file of your child theme.
So, to change the et-pb-post-main-image
image size, this is the code to be added in the functions.php file of your child theme.
unset( $image_sizes['400x250'] );
$image_sizes['500x350'] = 'et-pb-post-main-image';
return $image_sizes;
}
add_filter( 'et_theme_image_sizes', 'my_change_featured_size' );
This code will change et-pb-post-main-image
from 400×250 to 500×350.