Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Overwrite Additional Image Sizes of parent in child theme Wordpress

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 202
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: