'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => '' ), $attr)); $id = intval($id); if ('RAND' == $order) $orderby = 'none'; if (!empty($include)) { $include = preg_replace('/[^0-9,]+/', '', $include); $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); $attachments = array(); foreach ($_attachments as $key => $val) { $attachments[$val->ID] = $_attachments[$key]; } } if (empty($attachments)) return ''; $extra_class = ''; if (isset($attr['extra_class'])) { $extra_class .= ' ' . $attr['extra_class']; } $output = '
'; $output .= '
'; $row_class = 'col-md-3 col-sm-4 col-xs-6'; $thumb_size = 'medium'; if (isset($attr['columns'])) { //adds the proper sizes switch ($attr['columns']) { case '1': $row_class = 'col-md-12 col-sm-12 col-xs-12'; $thumb_size = 'full'; break; case '2': $row_class = 'col-md-6 col-sm-6 col-xs-6'; break; case '3': $row_class = 'col-md-4 col-sm-4 col-xs-6'; break; case '4': $row_class = 'col-md-3 col-sm-4 col-xs-6'; break; case '5': $row_class = 'col-md-2 col-sm-3 col-xs-6'; break; case '6': $row_class = 'col-md-2 col-sm-3 col-xs-6'; $thumb_size = 'small'; break; default: } } else { $row_class = 'col-md-4 col-sm-4 col-xs-6'; } if (isset($attr['style'])) { switch ($attr['style']) { case 'overflow-caption': $output .= gallery_overflow_caption($attachments, $row_class, $thumb_size); break; default: $output .= gallery_default($attachments, $row_class, $thumb_size); break; } } else { $output .= gallery_default($attachments, $row_class, $thumb_size); } $output .= "
"; //closes container and row return $output; } function register_gallery_styles() { wp_enqueue_style('bmatters-gallery', get_template_directory_uri() . '/assets/css/gallery.css'); } function gallery_overflow_caption($attachments, $row_class, $thumb_size) { $output = ''; foreach ($attachments as $id => $attachment) { $img = wp_get_attachment_image_src($id, $thumb_size); $output .= '
'; $output .= ''; //closes thumbnail $output .= '
'; //closes row } return $output; } function gallery_default($attachments, $row_class, $thumb_size) { $output = ''; foreach ($attachments as $id => $attachment) { $img = wp_get_attachment_image_src($id, $thumb_size); $output .= '
'; $output .= '' . _e('; $output .= '
'; } return $output; }