conditional $content_width /tiled galleries issue

Community Forums Forums Design Tips and Tricks conditional $content_width /tiled galleries issue

This topic is: not resolved

This topic contains 7 replies, has 3 voices, and was last updated by  braddalton 2 years, 4 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • #48912


    I’m using jetpack’s tiled galleries.

    My content size may be from 1080px or 708px depending or whether there is a sidebar or not.

    In functions.php I have included the code:

    if ( ! isset( $content_width ) )
    $content_width = 1080;

    to solve the issue of the tiled galleries defaulting to 500 px width.

    My question is how to create a conditional tag to change the $content width depending on the page template or whether there is a sidebar. This post indicated it’s not possible:

    but as indicated here the twentytwelve theme does just that:

    I haven’t been able to alter this code to work in genesis which works in twentytwelve:

    if ( ! isset( $content_width ) )
    $content_width = 625;

    function twentytwelve_content_width() {
    if ( is_page_template( 'full-width-page.php' ) || is_attachment() ) {
    global $content_width;
    $content_width = 960;
    add_action( 'template_redirect', 'twentytwelve_content_width' );

    Then I tried setting the default content width in functions.php and setting a different content width in different pages, but it just broke the page:


    on this page:

    the tiled galleries are showing up properly at the top and then as you scroll down the page they are going full width and still expanding into the sidebar.

    Any thoughts on setting a conditional $content_width’s?

    Thanks in advance.


    Might be right about that but this code will change the media embed size conditionally:



    Hi Brad,
    I’m not 100% if what I’m supposed to do I actually did correctly. But I’m have a similar issue with the Jetpack tiled gallery displaying full width on a page. I have selected the “full width” page (no sidebars) in the page’s layout. And copied/pasted the code you have above in my functions file. I increased the width to 1000 just to see if anything would happen. It did not resolve the problem.

    I have tried both “random” layouts and chronological order but that didn’t help the actual width of the gallery either…just the order in which the thumbnails appear. You can see the page I’m talking about below. Do you have any more suggestions as to how to fix this?



    The above code snippet is an example only and needs to be modified according to your own specific needs.

    The template name in included is a demo template name. You will need to change this by finding the template name in your source code or using a page i.d rather than template name in the conditional statement.



    Thanks again, but still not working. I changed
    is_page_template( 'full-width-content.php' ) to
    is_page( 719 ) — 719 is the page id for that specific page.

    I loaded the Twenty-twelve theme and the gallery will go to full page. And as you can see, the text goes to full page. It is only the gallery tiles that do not. So I’m starting to think that there is something about the Genesis themes that isn’t compatible with Jetpack’s tiled gallery. Which is a bummer.



    This is what i used for a single post and it works:

    This is what i used for a static page and it works:

    The problem is with the conditional tag rather than with Genesis which is 100% WordPress compatible and developed running bleeding nightlies (latest daily WordPress development version).

    is_page only works for pages
    is_single only works for posts



    Thank you Brad! That last code worked just fine. I’m using the “is_page” option as before. But now its working just as it did in the default theme. This is awesome because I’ve been looking all over the web. So many people are having issues with the tiled gallery (not just in Studio Press). You’re a genius. :)



    No worries Kary.

    Just published a post on it also.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.