From f10271ff0ad79f624bb939a197abeed127ad6d33 Mon Sep 17 00:00:00 2001 From: Foxaii Date: Wed, 31 Jul 2013 02:25:10 +0100 Subject: [PATCH] Update Gallery to BS3 --- assets/css/app.css | 3 +++ lib/cleanup.php | 12 ------------ lib/gallery.php | 36 ++++++++++++++++++++++++++++-------- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/assets/css/app.css b/assets/css/app.css index fa695eb..4ae0e4b 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -29,6 +29,9 @@ body { } .main { } +/* Gallery Shortcode */ +.row.gallery-row { padding: 15px 0; } + /* ========================================================================== Sidebar diff --git a/lib/cleanup.php b/lib/cleanup.php index 9594fc2..5759d9b 100644 --- a/lib/cleanup.php +++ b/lib/cleanup.php @@ -20,8 +20,6 @@ function roots_head_cleanup() { global $wp_widget_factory; remove_action('wp_head', array($wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style')); - add_filter('use_default_gallery_style', '__return_null'); - if (!class_exists('WPSEO_Frontend')) { remove_action('wp_head', 'rel_canonical'); add_action('wp_head', 'roots_rel_canonical'); @@ -137,16 +135,6 @@ function roots_embed_wrap($cache, $url, $attr = '', $post_ID = '') { } add_filter('embed_oembed_html', 'roots_embed_wrap', 10, 4); -/** - * Add class="thumbnail" to attachment items - */ -function roots_attachment_link_class($html) { - $postid = get_the_ID(); - $html = str_replace(' and
diff --git a/lib/gallery.php b/lib/gallery.php index 00f1582..a28693e 100644 --- a/lib/gallery.php +++ b/lib/gallery.php @@ -3,8 +3,9 @@ * Clean up gallery_shortcode() * * Re-create the [gallery] shortcode and use thumbnails styling from Bootstrap + * The number of columns must be a factor of 12. * - * @link http://twitter.github.com/bootstrap/components.html#thumbnails + * @link http://twbs.github.io/bootstrap/components/#thumbnails */ function roots_gallery($attr) { $post = get_post(); @@ -39,7 +40,7 @@ function roots_gallery($attr) { 'itemtag' => '', 'icontag' => '', 'captiontag' => '', - 'columns' => 3, + 'columns' => 4, 'size' => 'thumbnail', 'include' => '', 'exclude' => '', @@ -47,6 +48,8 @@ function roots_gallery($attr) { ), $attr)); $id = intval($id); + $columns = (12 % $columns == 0) ? $columns: 4; + $grid = sprintf('col-sm-%1$s col-lg-%1$s', 12/$columns); if ($order === 'RAND') { $orderby = 'none'; @@ -77,24 +80,41 @@ function roots_gallery($attr) { return $output; } - $output = ''; + + $output .= ($i % $columns != 0 ) ? '' : ''; + $output .= ''; return $output; } if (current_theme_supports('bootstrap-gallery')) { remove_shortcode('gallery'); add_shortcode('gallery', 'roots_gallery'); + add_filter('use_default_gallery_style', '__return_null'); } + +/** + * Add class="thumbnail img-thumbnail" to attachment items + */ +function roots_attachment_link_class($html) { + $postid = get_the_ID(); + $html = str_replace('