Esempio n. 1
0
 function gdlr_get_gallery_thumbnail($settings)
 {
     $item_id = empty($settings['page-item-id']) ? '' : ' id="' . $settings['page-item-id'] . '" ';
     global $gdlr_spaces;
     $margin = !empty($settings['margin-bottom']) && $settings['margin-bottom'] != $gdlr_spaces['bottom-item'] ? 'margin-bottom: ' . $settings['margin-bottom'] . ';' : '';
     $margin_style = !empty($margin) ? ' style="' . $margin . '" ' : '';
     $ret = '<div class="gdlr-gallery-item gdlr-item gdlr-gallery-thumbnail" ' . $item_id . $margin_style . '>';
     // full image
     $ret .= '<div class="gdlr-gallery-thumbnail-container">';
     foreach ($settings['slider'] as $slide_id => $slide) {
         $ret .= '<div class="gdlr-gallery-thumbnail" data-id="' . $slide_id . '" >';
         $ret .= gdlr_get_image($slide_id);
         if ($settings['show-caption'] != 'no') {
             $ret .= '<div class="gallery-caption-wrapper">';
             $ret .= '<span class="gallery-caption">';
             $ret .= gdlr_get_attachment_info($slide_id, 'caption');
             $ret .= '</span>';
             $ret .= '</div>';
         }
         $ret .= '</div>';
     }
     $ret .= '</div>';
     // start printing gallery
     $current_size = 0;
     foreach ($settings['slider'] as $slide_id => $slide) {
         if (!empty($current_size) && $current_size % $settings['gallery-columns'] == 0) {
             $ret .= '<div class="clear"></div>';
         }
         $ret .= '<div class="gallery-column ' . gdlr_get_column_class('1/' . $settings['gallery-columns']) . '">';
         $ret .= '<div class="gallery-item" data-id="' . $slide_id . '" >';
         $ret .= gdlr_get_image($slide_id, $settings['thumbnail-size']);
         $ret .= '</div>';
         // gallery item
         $ret .= '</div>';
         // gallery column
         $current_size++;
     }
     $ret .= '<div class="clear"></div>';
     $ret .= '</div>';
     // gdlr-gallery-item
     return $ret;
 }
function gdlr_gallery_shortcode($atts)
{
    if (!empty($atts['masterslider']) && $atts['masterslider'] == "true") {
        return gallery_shortcode($atts);
    }
    extract(shortcode_atts(array('columns' => '3', 'ids' => '', 'link' => 'post', 'type' => 'grid', 'caption' => 'yes', 'caption_position' => 'left', 'thumbnail_size' => 'thumbnail', 'size' => ''), $atts));
    $settings = array();
    $settings['show-caption'] = $caption;
    if (!empty($size)) {
        $settings['thumbnail-size'] = $size;
    } else {
        $settings['thumbnail-size'] = $thumbnail_size;
    }
    $settings['gallery-columns'] = $columns;
    $slides = array();
    $ids = explode(',', $ids);
    foreach ($ids as $slide_id) {
        $data = array();
        if ($link == 'file') {
            $data['slide-link'] = 'current';
        } else {
            if ($link == 'post') {
                $data['new-tab'] = 'disable';
                $data['slide-link'] = 'url';
                $data['url'] = get_permalink($slide_id);
            }
        }
        if ($type == 'slider' && $caption == 'yes') {
            $attachment = gdlr_get_attachment_info($slide_id);
            $data['title'] = $attachment['title'];
            $data['caption'] = $attachment['caption'];
            $data['caption-position'] = $caption_position;
        }
        $slides[$slide_id] = $data;
    }
    if (function_exists('gdlr_get_slider_item') && $type == 'slider') {
        $settings['slider-type'] = 'flexslider';
        return gdlr_get_flex_slider($slides, array('size' => $thumbnail_size));
    } else {
        if (function_exists('gdlr_get_gallery_thumbnail') && $type == 'thumbnail') {
            $settings['slider'] = $slides;
            return '<div class="gdlr-shortcode-wrapper">' . gdlr_get_gallery_thumbnail($settings) . '</div>';
        } else {
            if (function_exists('gdlr_get_gallery')) {
                $settings['slider'] = $slides;
                return '<div class="gdlr-shortcode-wrapper">' . gdlr_get_gallery($settings) . '</div>';
            }
        }
    }
    return '';
}