TwentySeventeen $content_width not updated in admin

I've read many answers to the problem of modifying TwentySeventeen's content width, but this one aspect is eluding me.

I have the following in my child theme's functions.php

function childtheme_content_width( $content_width ) {
    echo 'scriptconsole.log("$content_width was ' . $content_width . '")/script';
    if ( is_single() || is_admin() ) {
        $content_width = 800;
    }
    echo 'scriptconsole.log("$content_width now ' . $content_width . '")/script';
    return $content_width;
}
add_filter( 'twentyseventeen_content_width', 'childtheme_content_width', 11);

function my_custom_sizes( $sizes ) {
    return array_merge( $sizes, array(
    'post-perfect' = __( 'Full post width' ),
    ) );
}
add_filter( 'image_size_names_choose', 'my_custom_sizes' );

function add_new_image_size() {
    add_image_size ( 'post-perfect', 800, 800);
}
add_action( 'after_setup_theme', 'add_new_image_size', 11 );

According to my reading, that should allow for 800 pixel wide content in single pages (and admin) and add a new image size "Full post width" which should be 800 pixels wide.

However, while I can prove from the console that the width is correctly set from 525 to 800 when viewing a single post (and embeds expand to fill this), when I am in the editor the code does not run (there is no output from the console.log) and I assume this is the reason why the "Full post width" image size shows up with a width of 525 in the drop-down list of sizes.

What am I missing to make this change to $content_width work during editing and therefore (I assume) allow for 800-pixel wide images?

Topic theme-twenty-seventeen content-width media images Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.