JetPack Tiled Gallery fix

Community Forums Forums Design Tips and Tricks JetPack Tiled Gallery fix

This topic is: not resolved

This topic contains 4 replies, has 4 voices, and was last updated by  ameeker 3 months, 1 week ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #9934

    acekin
    Participant
    Post count: 1

    I use the Crystal Child Theme on my site, keptlight.com. Recently an update to JetPack plugin offered a new way of presenting galleries called tiled gallery. I tested it and found that the presentation did not fill the entire width of the content area and filed a bug report with the plugin. The developer recommended that I try adding the following to the functions.php and it worked. This is a workaround until the fix may make its way to the theme update. By the way, there is another small bug I reported which deals with the slideshow presentation anomaly. You can see it in the second slide in the slideshow, the right border almost disappears. That will be fixed in the next JetPack update.

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

    I disabled this code segment so that you can see the gallery presentation:
    http://www.keptlight.com/2013/01/test-tiled-galleries/

    #13273

    Stefano Dotta
    Participant
    Post count: 4

    Hello Cemal,

    I actually ran into the same issue a few days ago, when I started playing with the new tiled gallery from the Jetpack.

    After some digging in the php files of the Jetpack plugin, I came across this function that defines the tiled gallery width to be used by default, if the variable $content_with is not defined or empty: (/wp-content/plugins/jetpack/modules/tiled-gallery/tiled-gallery.php)

    public static function get_content_width() {
    global $content_width;

    $tiled_gallery_content_width = $content_width;

    if ( ! $tiled_gallery_content_width )
    $tiled_gallery_content_width = 500;

    return apply_filters( ’tiled_gallery_content_width’, $tiled_gallery_content_width );
    }

    The theme I use on my site (News) defines a $content_with of 580px, according to this line found in the functions.php of the theme:
    $content_width = apply_filters( ‘content_width’, 580, 430, 910 );

    Not sure where and when the  two other values are used, but 910px it’s actually the width of my content when I use a full page width, according to Firebug.

    BTW, I have created  a custom post type to display my galleries, following the tutorial provided by Brian from StudioPress.

    I therefore “hard coded” the variable  in my single-portfolio.php file and my galleries are now taking the whole page width.
    $content_width=910;

    Not sure it follows the best practices in term of coding, but it works…
    http://www.twoswisshikers.net/portfolio/jura-en-hiver/ (in French only)

    And by the way, on all other pages or posts, the content width is reverted back to 580px, I guess taking the value defined in the functions.php file.

    Question:
    Can somebody explain the purpose of the three content_width values defined in the functions.php file and how to use them in order to avoid doing any hard-coding?

    Many thanks in advance,


    Stefano, an avid hiker from Switzerland.
    http://www.twoswisshikers.net/

    #13279

    Bill Murray
    Participant
    Post count: 463

    I haven’t looked at the code, but from what I’ve read, $content_width is not technically width of the content. It’s the width of embedded content such as images or videos. The 3 values represent that width when 1,2 or 0 sidebars are displaying.

    I therefore “hard coded” the variable in my single-portfolio.php file and my galleries are now taking the whole page width.
    $content_width=910;

    This makes perfect sense in light of the way $content_width works. If your single-portfolio.php also displays a sidebar, that might be too wide though.

    For $content_width and mobile responsive issues, this might be helpful.


    Twitter: @wpperform

    #13301

    Stefano Dotta
    Participant
    Post count: 4

    Bill,

    Thank you for your answer and the link provided.

    Actually the single-portfolio.php is a full-width page and has no sidebars.

    Regards,


    Stefano, an avid hiker from Switzerland.
    http://www.twoswisshikers.net/

    #19703

    ameeker
    Participant
    Post count: 12

    I had this same question today, except using the Executive theme, and with the intent to use a tiled gallery in a widget in an area that is full width on the home page. When I asked over at the WP forums, they suggested I look to the TwentyTwelve theme for direction on how to filter the content width per page template, which I tried using this below, but it didn’t work (used in the functions file, and took out a || ! is_active_sidebar( ’sidebar-1′ ) along the way in the original example here: http://core.trac.wordpress.org/browser/trunk/wp-content/themes/twentytwelve/functions.php#L414).

    /**
    * Adjusts content_width value for full-width and single image attachment
    * templates, and when there are no active widgets in the sidebar.
    *
    * @since Twenty Twelve 1.0
    */
    function twentytwelve_content_width() {
    if ( is_page_template( 'page-templates/home.php' ) || is_attachment() ) {
    global $content_width;
    $content_width = 1140;
    }
    }
    add_action( 'template_redirect', 'twentytwelve_content_width' );

     

    Any thoughts about how to get that to work?

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

You must be logged in to reply to this topic.