• Here is what I have in parent functions.php

    // Set image sizes upon theme activation
    if(! function_exists( 'theme_image_setup' )):
        function theme_image_setup() {
            // updating thumbnail and image sizes
            update_option('thumbnail_size_w', 200);
            update_option('thumbnail_size_h', 150);
            update_option('medium_size_w', 620);
            update_option('medium_size_h', '');
            update_option('large_size_w', 940);
            update_option('large_size_h', '');
        }
    endif;
    
    add_action( 'switch_theme', 'theme_image_setup' );

    and in child

    function theme_image_setup() {
        // updating thumbnail and image sizes
        update_option( 'thumbnail_size_w', 150, true );
        update_option( 'thumbnail_size_h', 150, true );
        update_option( 'medium_size_w', 620, true );
        update_option( 'medium_size_h', '', true );
        update_option( 'large_size_w', '', true );
        update_option( 'large_size_h', 500, true );
    }

    This looks like it will work perfectly, child overriding parent theme. The problem is it is reverse. When I activate parent theme, the settings from child is coming and vice versa. This code updates the media setting under Settings -> Media. What am I doing wrong? Any help is greatly appreciated. Thanks.

Viewing 4 replies - 16 through 19 (of 19 total)
  • Thread Starter Chandra M

    (@nhuja)

    Its not that easy. ?? The main issue was to set the image dimensions in the Media page as you activate the theme. add_image_size doesn’t do this. Even if we add that, we will need to manually change the sizes in the Settings->Media page. We just wanted to make things easier for the user and as you might know this is the most ignored part by WordPress users. ??

    OK, I se what you mean. I’d still use the add image size to make it easy for yourself, otherwise you’ve got to make a database call to change those settings?? Which is clunky of course.

    Thread Starter Chandra M

    (@nhuja)

    Yea, we could use that but you are only creating multiple instances of images which could easily be done with just those sizes, you know. ?? Anyway, we concluded we would leave it just as it is so its all good. We did spend like 2 weeks on this. ??

    I hear ya! Might be one to put on the WP feature request forum? There’s a lot of interesting talk about how the media library works right now.

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘Child function not overriding parent function / acts opposite’ is closed to new replies.