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 1 year ago.

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

    jgk
    Participant
    Post count: 21

    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:

    http://wordpress.stackexchange.com/questions/6499/how-to-create-a-conditional-content-width-for-a-wordpress-theme

    but as indicated here the twentytwelve theme does just that:

    http://core.trac.wordpress.org/ticket/21256

    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:

    $content_width=910;

    on this page:

    http://jgtest.wpengine.com/blog/

    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.

    http://jgtest.wpengine.com/blog/
    #48932

    braddalton
    Participant
    Post count: 9223

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


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #53104

    Kary
    Participant
    Post count: 53

    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?
    Thanks.

    http://www.unstuckification.com/artwork/

    #53145

    braddalton
    Participant
    Post count: 9223

    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.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #53158

    Kary
    Participant
    Post count: 53

    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.

    #53166

    braddalton
    Participant
    Post count: 9223

    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).
    [php]
    is_page only works for pages
    is_single only works for posts
    [/php]


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #53171

    Kary
    Participant
    Post count: 53

    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. :)

    #53174

    braddalton
    Participant
    Post count: 9223

    No worries Kary.

    Just published a post on it also.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

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

You must be logged in to reply to this topic.