/** * Lightbox * * @since 1.1.0 * * @param array $atts Standard WordPress shortcode attributes * @param string $content Content in shortcode * @return string $output Content to output for shortcode */ function themeblvd_shortcode_lightbox($atts, $content = null) { // Shortcode requires framework 2.3+ if (!function_exists('themeblvd_is_lightbox_url')) { $error = __('You must be using a theme with Theme Blvd framework v2.3+ to use the [lightbox] shortcode.', 'themeblvd_shortcodes'); return sprintf('<div class="alert">%s</div>', $error); } $default = array('link' => '', 'thumb' => '', 'caption' => '', 'width' => '', 'align' => 'none', 'title' => '', 'frame' => 'true', 'frame_max' => 'true', 'icon' => 'image', 'class' => ''); $atts = shortcode_atts($default, $atts); $output = ''; // Setup thumbnail, can be image or text string $thumb = $atts['thumb']; $has_thumb_img = false; $thumb_type = wp_check_filetype($thumb); if (substr($thumb_type['type'], 0, 5) == 'image') { $has_thumb_img = true; // Build <img /> HTML for thumbnail $thumb = sprintf('<img src="%s" alt="%s"', $thumb, $atts['title']); if ($atts['width']) { $thumb .= sprintf(' width="%s"', $atts['width']); } if ($atts['frame'] == 'false' && $atts['align'] != 'none') { // If image is framed, the alignment will be on the frame $thumb .= sprintf(' class="align%s"', $atts['align']); } $thumb .= ' />'; } // Add image overlay if framed thumbnail if ($atts['frame'] == 'true' && $has_thumb_img) { $thumb .= themeblvd_get_image_overlay(); } // Classes for link's anchor tag $anchor_classes = ''; if ($atts['frame'] == 'true') { $anchor_classes .= 'thumbnail ' . $atts['icon']; } if ($atts['frame'] == 'false' && $atts['class']) { $anchor_classes .= $atts['class']; } if ($atts['caption']) { $anchor_classes .= ' has-caption'; } // Wrap thumbail image/text in link to lightbox $args = apply_filters('themeblvd_lightbox_shortcode_args', array('item' => $thumb, 'link' => $atts['link'], 'title' => $atts['title'], 'class' => $anchor_classes), $atts); $output .= themeblvd_get_link_to_lightbox($args); // Wrap link and thumbnail image in frame if ($atts['frame'] == 'true' && $has_thumb_img) { // Wrapping CSS classes $wrap_classes = 'tb-lightbox-shortcode'; if ($atts['align'] != 'none') { $wrap_classes .= ' align' . $atts['align']; } if ($atts['class']) { $wrap_classes .= ' ' . $atts['class']; } // Force inline styling $style = ''; if ($atts['width'] && $atts['frame_max'] == 'true') { $style = sprintf('max-width: %spx', $atts['width']); } $wrap = '<div class="' . $wrap_classes . '" style="' . $style . '">'; $wrap .= '<div class="featured-image-wrapper">'; $wrap .= '<div class="featured-image">'; $wrap .= '<div class="featured-image-inner">'; $wrap .= '%s'; // Caption if ($atts['caption']) { $wrap .= sprintf('<p class="wp-caption-text">%s</p>', $atts['caption']); } $wrap .= '</div><!-- .featured-image-inner (end) -->'; $wrap .= '</div><!-- .featured-image (end) -->'; $wrap .= '</div><!-- .featured-image-wrapper (end) -->'; $wrap .= '</div>'; $wrap = apply_filters('themeblvd_lightbox_shortcode_thumbnail_wrap', $wrap, $wrap_classes, $style); $output = sprintf($wrap, $output); } else { if ($atts['caption']) { $output .= sprintf('<p class="wp-caption-text">%s</p>', $atts['caption']); } } return apply_filters('themeblvd_shortcode_lightbox', $output, $atts, $thumb); }
/** * 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; }
/** * Get the final image output for an image slide * * @since 1.1.0 * * @param array $atts Media attributes from themeblvd_sliders_get_media_atts() * @param string $slider_type Type of slider, standard, nivo, carrousel, bootstrap, or fallback * @return string $output HTML output for image */ function themeblvd_sliders_get_image($atts, $slider_type = 'standard') { $lightbox = false; $output = ''; $link_target = ''; // Image $image = sprintf('<img src="%s" alt="%s" width="%s" height="%s" />', $atts['url'], $atts['alt'], $atts['width'], $atts['height']); // Image Link if ($atts['link']) { // Link class and target switch ($atts['link']['target']) { case 'lightbox_video': $lightbox = true; $anchor_class = 'slide-thumbnail-link video'; break; case 'lightbox': $lightbox = true; $anchor_class = 'slide-thumbnail-link image'; break; case '_blank': $anchor_class = 'slide-thumbnail-link external'; $link_target = $atts['link']['target']; break; default: $anchor_class = 'slide-thumbnail-link post'; $link_target = $atts['link']['target']; } // Markup used for image overlay in to work with framework javascript $overlay = ''; if ($slider_type != 'fallback') { if (function_exists('themeblvd_get_image_overlay')) { $overlay = themeblvd_get_image_overlay(); } else { $overlay = '<span class="image-overlay"><span class="image-overlay-bg"></span><span class="image-overlay-icon"></span></span>'; } } $overlay = apply_filters('themeblvd_sliders_image_overlay', $overlay, $atts, $link_target, $slider_type); // Wrap image in link if ($lightbox && function_exists('themeblvd_get_link_to_lightbox')) { $args = apply_filters('themeblvd_sliders_lightbox_args', array('item' => $image . $overlay, 'link' => $atts['link']['url'], 'class' => $anchor_class, 'title' => $atts['link']['title']), $atts, $image, $slider_type); $output = themeblvd_get_link_to_lightbox($args); } else { $output = sprintf('<a href="%s" title="%s" target="%s" class="%s">%s</a>', $atts['link']['url'], $atts['link']['title'], $link_target, $anchor_class, $image . $overlay); } } else { // Output set to the raw image when there's no link $output .= $image; } return apply_filters('themeblvd_sliders_image', $output, $atts, $image, $slider_type, $lightbox); }
/** * Take a piece of markup and wrap it in a link to a lightbox. * * @since 2.3.0 * * @param $args array Arguments for lightbox link */ function themeblvd_link_to_lightbox($args) { echo themeblvd_get_link_to_lightbox($args); }