Hello users, today I teach you How to Overwrite Additional Image Sizes of parent in child theme Wordpress.
Below code is the Parent theme for image cropping.
add-action( 'after-setup-theme', 'setup' );
function setup()
{
add-image-size( 'slider-img', 1140, 455, true );
add-image-size( 'post-thumb', 235, 254, true );
}
You can overwrite the above code into your child theme.
First, unset the parent theme image crop function then put your custom code into functions.php file
Just copy the below code.
add-filter( 'intermediate-image-sizes-advanced', 'remove-parent-image-sizes' );
function remove-parent-image-sizes( $sizes ) {
unset( $sizes['slider-img'] );
unset( $sizes['post-thumb'] );
return $sizes;
}
if ( function-exists( 'add-image-size' ) ) {
add-image-size( 'slider-img', 700, 400, true );
add-image-size( 'post-thumb', 320, 240, true );
}
0 Comment(s)