/** * Get Mini Post Grid * * @since 2.1.0 * * @param array $options Options for many post grid * @return string $output HTML to output */ function themeblvd_get_mini_post_grid($query = '', $align = 'left', $thumb = 'smaller', $gallery = '') { global $post; global $_wp_additional_image_sizes; $output = ''; // CSS classes $classes = $thumb . '-thumbs'; $classes .= ' grid-align-' . $align; if ($gallery) { $classes .= ' gallery-override themeblvd-gallery'; } // Thumb size $thumb_size = apply_filters('themeblvd_mini_post_grid_thumb_size', 'square_' . $thumb, $thumb, $query); $thumb_width = $_wp_additional_image_sizes[$thumb_size]['width']; // Check for gallery override $gallery_link = ''; if ($gallery) { $pattern = get_shortcode_regex(); if (preg_match("/{$pattern}/s", $gallery, $match) && 'gallery' == $match[2]) { $atts = shortcode_parse_atts($match[3]); if (isset($atts['link']) && 'file' == $atts['link']) { $gallery_link = 'file'; } if (!empty($atts['ids'])) { $query = array('post_type' => 'attachment', 'post__in' => explode(',', $atts['ids']), 'posts_per_page' => -1); } } } // Format query if (!is_array($query)) { $query = html_entity_decode($query); } // Get posts $posts = get_posts($query); // Start output if ($posts) { $output = '<div class="themeblvd-mini-post-grid">'; $output .= '<ul class="' . $classes . '">'; foreach ($posts as $post) { setup_postdata($post); $output .= '<li>'; if ($gallery) { // Gallery image output to simulate featured images $thumbnail = wp_get_attachment_image_src($post->ID, apply_filters('themeblvd_mini_post_grid_thumb_size', 'square_' . $thumb, $thumb, $query, $align, $gallery)); $output .= '<div class="featured-image-wrapper">'; $output .= '<div class="featured-image">'; $output .= '<div class="featured-image-inner">'; if ('file' == $gallery_link) { $image = wp_get_attachment_image_src($post->ID, 'full'); $item = sprintf('<img src="%s" alt="%s" />', $thumbnail[0], $post->post_title); $args = array('item' => $item . themeblvd_get_image_overlay(), 'link' => $image[0], 'title' => $post->post_title, 'class' => 'image thumbnail', 'gallery' => true); $output .= themeblvd_get_link_to_lightbox($args); } else { $output .= sprintf('<a href="%s" title="%s" class="image thumbnail">', get_permalink($post->ID), $post->post_title, $gallery); $output .= sprintf('<img src="%s" alt="%s" />', $thumbnail[0], $post->post_title); $output .= themeblvd_get_image_overlay(); $output .= '</a>'; } $output .= '</div><!-- .featured-image-inner (end) -->'; $output .= '</div><!-- .featured-image (end) -->'; $output .= '</div><!-- .featured-image-wrapper (end) -->'; } else { // Standard featured image output $image = themeblvd_get_post_thumbnail('primary', $thumb_size); // If post thumbnail isn't set, pull default thumbnail // based on post format. If theme doesn't support post // formats, format will always be "standard". if (!$image) { $default_img_directory = apply_filters('themeblvd_thumbnail_directory', get_template_directory_uri() . '/framework/assets/images/thumbs/2x/'); $post_format = get_post_format(); if (!$post_format) { $post_format = 'standard'; } $image .= '<div class="featured-image-wrapper attachment-' . $thumb_size . ' thumbnail">'; $image .= '<div class="featured-image">'; $image .= '<div class="featured-image-inner">'; $image .= sprintf('<a href="%s" title="%s">', get_permalink(), get_the_title()); $image .= sprintf('<img src="%s.png" width="%s" class="wp-post-image" />', $default_img_directory . $thumb . '_' . $post_format, $thumb_width); $image .= '</a>'; $image .= '</div><!-- .featured-image-inner (end) -->'; $image .= '</div><!-- .featured-image (end) -->'; $image .= '</div><!-- .featured-image-wrapper (end) -->'; } $output .= $image; } $output .= '</li>'; } wp_reset_postdata(); $output .= '</ul>'; $output .= '<div class="clear"></div>'; $output .= '</div><!-- .themeblvd-mini-post-list (end) -->'; } else { $output = themeblvd_get_local('archive_no_posts'); } return $output; }
/** * Default display for action: themeblvd_the_post_thumbnail * * @since 2.0.0 * * @param string $location Where the thumbnail is being used -- primary, featured, single -- sort of a wild card to build on in the future as conflicts arise. * @param string $size For the image crop size of the thumbnail * @param bool $link Set to false to force a thumbnail to ignore post's Image Link options * @param bool $allow_filters Whether to allow general filters on the thumbnail or not */ function themeblvd_the_post_thumbnail_default($location = 'primary', $size = '', $link = true, $allow_filters = true) { echo themeblvd_get_post_thumbnail($location, $size, $link, $allow_filters); }