2

I'm using a child theme of a parent theme. Now on my parent theme, theveloper adds some custom image sizes like this -

if ( function_exists( 'add_image_size' ) )
    {
        add_image_size( 'blog_feat_img', 1300 );
        add_image_size( 'latest_posts_widget_feat_img', 720 );
        add_image_size( 'portfolio_widget_feat_img_1x', 600 );
        add_image_size( 'portfolio_widget_feat_img_2x', 900 );
    }

Now I want to change the values is set default in my partent theme's functions.php so searched Google and use every single alternative suggested there.

Starting with this:

I even tried to achieve it by doing this

update_option( 'blog_feat_img', 720 ); 

but no matter what I do the theme is still loading my parent theme's add_image_size() values.

I've also written this following function to achieve this -

function img_update() {
    add_image_size( 'blog_feat_img', 720 );
    add_image_size( 'latest_posts_widget_feat_img', 400 );
    add_image_size( 'portfolio_widget_feat_img_1x', 400 );
    add_image_size( 'portfolio_widget_feat_img_2x', 800 );
}
add_action( 'after_setup_theme', 'img_update', 11 );

None of these is actually working. Any suggestions?

  • Have you regenerated the images using Regenerate Thumbnails or the like after the last bit of code? It should work. – Mayeenul Islam Dec 22 '14 at 10:23
  • Regenerated several times. :( – iSaumya Dec 22 '14 at 10:24
  • 1
    The problem is that functions.php file of child theme is loaded before parent's file, so you add the custom image sizes and afer that your parent theme overrides them. We need to know the action hook where the parent theme is adding the image sizes to see if it is possible to override them after it is done. Not always all options of a theme are reaady to be overriden by child themes; it depends on how the developer built the theme. Also, note that third party themes and plugins are off-topic and it maybe better if you ask to the developer. – cybmeta Dec 22 '14 at 12:15
  • Its ok. I figured it out at last :) – iSaumya Dec 22 '14 at 14:33
  • 1
    How did you do it? I have the same problem. The images are set in the parent theme with add_image_size(). – Tamara Jul 22 '17 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.