• Hi
    I am creating a child theme based on 2016

    I want to set new upload media images

    add_action( 'after_setup_theme', 'azm_add_image_size' );
    function azm_add_image_size() {
      add_image_size( 'helen', 936 );
      add_image_size( 'brian', 227 );
    }
    
    add_filter( 'image_size_names_choose', 'my_custom_sizes' );
    function my_custom_sizes( $sizes ) {
        return array_merge( $sizes, array(
           'helen' => __( 'helen' ),
            'brian' =>__( 'brian')
        ) );
    }

    The small size, brian, works fine.

    However the large size is creating the correct image in the uploads folder eg ‘bluehousefrontelevation-1-936×624.jpg’

    however, in the backend the media library is showing helen-840×560 and it adds the wrong width/height sizes into the code.

    I have tired suggestions at https://codex.wordpress.org/Content_Width and core ticket

    Nothing seems to work.

    The only way i can find to get round it is to edit the functions.php within 2016 – which obviously I don’t really want to do – here’s what i edit:

    function twentysixteen_content_width() {
    //  $GLOBALS['content_width'] = apply_filters( 'twentysixteen_content_width', 840 );
        $GLOBALS['content_width'] = apply_filters( 'twentysixteen_content_width', 2000 );
    }
    add_action( 'after_setup_theme', 'twentysixteen_content_width', 0 );

    Is there are better way to change this (annoying) variable please?

The topic ‘over-riding $content_width not working’ is closed to new replies.