Support » Theme: Twenty Seventeen » full width blog, images/galleries stuck at 525/740

  • I almost have a one column version working, but some images are still limited by the twentyseventeen_content_width function (I think), and I can’t seem to override it.

    Large size images are stuck at 525px, and appear to be following the $GLOBALS[‘content_width’] = 525; in the Twenty Seventeen functions.

    Jetpack tiled galleries are stuck at 740px, and appear to be following the twentyseventeen_content_width function.

    I’ve tried to reset the content width following information at https://make.wordpress.org/core/2016/11/29/theming-with-twenty-seventeen/ but that didn’t change anything.

    So two questions, probably related:

    1) How can I convince it to display Large images at the size specified in WordPress Admin panel?
    2) How can I convince the Jetpack tiled gallery to display at full width?

    Thanks in advance!

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter jamescockroft

    (@jamescockroft)

    Resetting the content width appears to do nothing… I copied/pasted this code directly from the website referenced above and it appears to do nothing.

    function childtheme_content_width( $content_width ) {
        if ( twentyseventeen_is_frontpage() ) {
            $content_width = 960;
        }
        return $content_width;
    }
    add_filter( 'twentyseventeen_content_width', 'childtheme_content_width' );

    I tried killing the twentyseventeen_content_width_attr filter with:

    function child_remove_twentyseventeen_content_image_sizes_attr() {
        remove_filter( 'wp_calculate_image_sizes', 'twentyseventeen_content_image_sizes_attr', 10, 2 );
    }
    add_action( 'wp_loaded', 'child_remove_twentyseventeen_content_image_sizes_attr' );

    Nothing.

    I tried to write my own version:

    function jcseventeen_content_image_sizes_attr( $sizes, $size ) {
    	$width = $size[0];
    
    	if ( 740 <= $width ) {
    		$sizes = '(max-width: 706px) 100vw, (max-width: 767px) 100vw, 1000px';
    	}
    
    	if ( is_active_sidebar( 'sidebar-1' ) || is_archive() || is_search() || is_home() || is_page() ) {
    		if ( ! ( is_page() && 'one-column' === get_theme_mod( 'page_options' ) ) && 767 <= $width ) {
    			 $sizes = '(max-width: 767px) 100vw, (max-width: 1000px) 100vw, (max-width: 1071px) 1000px, 1000px';
    		}
    	}
    
    	return $sizes;
    }
    add_filter( 'get_parent_theme_file_path', 'jcsventeen_remove_twentyseventeen_content_image_sizes_attr', 15, 2 ); 

    Nothing.

    Any suggestions? Where am I going wrong?

    This worked for me, it is only slightly different, I’m still playing around with the sizes so use your own.

    
    function remove_parent_filters(){ //Have to do it after theme setup, because child theme functions are loaded first
        remove_filter('wp_calculate_image_sizes', 'twentyseventeen_content_image_sizes_attr', 10);
    }
    add_action( 'after_setup_theme', 'remove_parent_filters' );
    
    function child_content_image_sizes_attr( $sizes, $size ) {
    	$width = $size[0];
    
    	if ( 740 <= $width ) {
    		$sizes = '(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px';
    	}
    
    	if ( is_active_sidebar( 'sidebar-1' ) || is_archive() || is_search() || is_home() || is_page() ) {
    		if ( ! ( is_page() && 'one-column' === get_theme_mod( 'page_options' ) ) && 767 <= $width ) {
    			 $sizes = '(max-width: 767px) 89vw, (max-width: 1000px) 85vw, (max-width: 1071px) 700px, 1020px';
    		}
    	}
    
    	return $sizes;
    }
    add_filter( 'wp_calculate_image_sizes', 'child_content_image_sizes_attr', 15, 2 );
    
    Thread Starter jamescockroft

    (@jamescockroft)

    Thanks!

    That doesn’t work for me for some reason.

    The WordPress display settings panel (when you Add Media) shows large images as max width 525. If I set a custom size, it respects it. But my Media settings have Large images at 800 wide, and if I regenerate thumbnails, it generates 800px wide Large images.

    Jetpack galleries still show at 740 px wide too.

    I’m going to experiment a bit. It could be some other function or css in my theme tearing stuff up.

    Ah yes, I also adjusted the .wrap css styles.

    Again, I”m still experimenting with sizes, so just experiment with both the function and the styles to get what you want.

    Compare this to your current CSS:

    
     @media screen and (min-width: 48em) { /* 768 px */
    .wrap {
        max-width: 700px;
        padding-left: 1em;
        padding-right: 1em;
    }
     } 
     @media screen and (min-width: 75em) { /* 1200 px */
    .wrap {
        max-width: 1400px;
        padding-left: 3em;
        padding-right: 3em;
    }
    .single-post:not(.has-sidebar) #primary, .page.page-one-column:not(.twentyseventeen-front-page) #primary, .archive.page-one-column:not(.has-sidebar) .page-header, .archive.page-one-column:not(.has-sidebar) #primary {
        margin-left: auto;
        margin-right: auto;
        max-width: 1140px;
    }
     }
    
    Thread Starter jamescockroft

    (@jamescockroft)

    Thanks again. Still no joy.

    I’ve tried disabling all plugins, I’ve tried a fresh child theme, everything I can think of. Something, somewhere is causing wordpress and jetpack to see the content width setting in twenty seventeen.

    I’ll keep playing. It could be something in my dev server too, so I’ll probably wipe it and start from scratch everywhere.

    I don’t use JetPack so can’t help there. Do you need JetPack?

    Thread Starter jamescockroft

    (@jamescockroft)

    Probably not, but if I can solve the issue with Large images, that should also solve the issues with Jetpack galleries.

    (The problem persists even with Jetpack deactivated.)

    I’m getting tired of messing with it to be honest, but I think a solution is out there somewhere.

    Hey there,
    I had a similar issue, and you can find my results on the topic I posted today: https://wordpress.org/support/topic/twentyseventeen-large-media-stuck-at-525px-or-580px/

    Hope that helps if you’re still troubleshooting!

    Hello @jamescockroft, did you find a solution for this problem?
    I have the same issue and also tried everything everyones has suggested with no luck. Thanks!

    Thread Starter jamescockroft

    (@jamescockroft)

    Hi agpashion, I never did, but I got happy enough with it.

    With my current settings, large images are still stuck at 525px, and galleries are stuck at 800px. Custom sizes work, and full size gets resized to the max width.

    I never used many large images anyway, so this isn’t a huge problem for me. I’d still love to find a fix, but the image sizes are hard coded in the parent theme functions file, and I’ve tried all kinds of things, but still haven’t found a way to overwrite those functions in my child theme.

    Here are the relevant sections from my functions file:

    Up at the top of the functions file for my child theme, I entered:
    remove_filter( 'wp_calculate_image_sizes', 'twentyseventeen_content_image_sizes_attr' );

    This did something, I think… I’m not sure what, to be honest. It’s been awhile since I messed with this.

    Lower down, I set a new default content width:

    function childtheme_content_width( $content_width ) {
        if ( twentyseventeen_is_frontpage() ) {
            $content_width = 1200;
        }
        return $content_width;
    }
    add_filter( 'theme_setup', 'childtheme_content_width' );

    Sorry I can’t be more help!

    I have managed to get the text area wider, and I have managed to get the Jetpack tiled gallery to fill the text area. But jetpack seems to impact normal image display so I am still unable to get a normal image to fill the text area 100%. As soon as I turn off tiled galleries the images will show at 100% of the text area’s width …

    Here’s what has worked for me in a child theme.

    In functions.php:

    if ( ! isset( $content_width ) )
        $content_width = 1600;
    
    function prefix_child_theme_setup() {
        // Set the default content width.
    	$GLOBALS['content_width'] = 1600;
        remove_filter( 'wp_calculate_image_sizes', 'twentyseventeen_content_image_sizes_attr' );
    }
    add_action( 'after_setup_theme', 'prefix_child_theme_setup', 11 );
    
    add_filter( 'tiled_gallery_content_width', 'wpsites_custom_tiled_gallery_width' );
    /**
     * @author    Brad Dalton
     * @example   http://wpsites.net/
     * @copyright 2014 WP Sites
     */
    function wpsites_custom_tiled_gallery_width($width){
        $tiled_gallery_content_width = $width;
        $width = 900;
        return $width;
    }

    In style.css (I’ve set a max width of 900px for a desktop display).

    /*    RESET HOME PAGE WIDTH FOR DESKTOPS*/
    
    @media screen and (min-width: 30em) {
    .page-one-column .panel-content .wrap {
        max-width: 900px;
    }
    }
    
    /* RESET POST WIDTH FOR DESKTOPS */
    
    .single-post:not(.has-sidebar) #primary, .page.page-one-column:not(.twentyseventeen-front-page) #primary, .archive.page-one-column:not(.has-sidebar) .page-header, .archive.page-one-column:not(.has-sidebar) #primary {
        margin-left: auto;
        margin-right: auto;
        max-width: 900px;
    }

    This (apart from images being limited to 644px wide) seems to work fine. I updated the default image sizes in Settings Media to be 150, 900 and 1600px respectively.

    For anyone wanting to tailor a theme, Twenty Seventeen seems to be one of the worst designed Themes WordPress has produced in many years. The use of hard-coded parameters instead of CSS is an unmitigated disaster. I have lost count of the hours I have spent going round and round in circles trying to fix this.

    I hope someone has a solution.

    And, I’ve spent as many hours looking for a replacement for jetpack tiled galleries as an alternate solution. None of them work exactly as they should — I’ve tried at least six — they all foul up at some point, or won’t coexist with my existing plugins.

    • This reply was modified 4 years, 10 months ago by Gary Allman.

    Thanks @jamescockroft and @gsallman !
    I still couldn’t find a solution, but a couple of hacks helped mask the problem.
    I agree with you about Twenty Seventeen, Gary. It’s probably the result of the obsession about improving websites performance for mobile versions, which is great and all, but it can be very annoying sometimes.
    I would love to find a plugin to replace jetpack’s tiled gallery as well. Let me know if you do!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘full width blog, images/galleries stuck at 525/740’ is closed to new replies.