1 Answers
DominicStaff
answered 8 years ago

Hi,
At the moment, our theme does not compatible with Jetpack Gallery. If you want to use the Jetpack gallery, you can open the template-tags.php file, you can find and remove the following code from the line 311 to line 412.

if( ! function_exists('dw_gallery_shortcode') ) {
    function dw_gallery_shortcode($attr) {
        $post = get_post();
        static $instance = 0;
        $instance++;
        if ( ! empty( $attr['ids'] ) ) {
            if ( empty( $attr['orderby'] ) )
                $attr['orderby'] = 'post__in';
            $attr['include'] = $attr['ids'];
        }
        $output = apply_filters('post_gallery', '', $attr);
        if ( $output != '' )
            return $output;
        if ( isset( $attr['orderby'] ) ) {
            $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
            if ( !$attr['orderby'] )
                unset( $attr['orderby'] );
        }
        extract(shortcode_atts(array(
            'order'      => 'ASC',
            'orderby'    => 'menu_order ID',
            'id'         => $post->ID,
            'itemtag'    => 'li',
            'icontag'    => 'dt',
            'captiontag' => 'dd',
            'columns'    => 3,
            'size'       => 'thumbnail',
            'include'    => '',
            'exclude'    => ''
        ), $attr));
        $id = intval($id);
        if ( 'RAND' == $order )
            $orderby = 'none';
        if ( !empty($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];
            }
        } elseif ( !empty($exclude) ) {
            $attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
        } else {
            $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
        }
        if ( empty($attachments) )
            return '';
        if ( is_feed() ) {
            $output = "\n";
            foreach ( $attachments as $att_id => $attachment )
                $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
            return $output;
        }
        $itemtag = tag_escape($itemtag);
        $captiontag = tag_escape($captiontag);
        $columns = intval($columns);
        $itemwidth = $columns > 0 ? floor(100/$columns) : 100;
        $float = is_rtl() ? 'right' : 'left';
        $selector = "gallery-{$instance}";
        $gallery_style = $gallery_div = '';
        $size_class = sanitize_html_class( $size );
        $gid = rand();
        $carousel_div = "<div id='gallery-{$id}{$gid}' class='gallery carousel slide'> <div class='carousel-inner'>";
        $output .= apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $carousel_div );
        $i = 0;
        $thumbnails = array();
        foreach ( $attachments as $img_id => $attachment ) {
            $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($img_id, $size, false, false) : wp_get_attachment_link($img_id, $size, true, false);
            $full_url= wp_get_attachment_image_src( $img_id,'full');
            $thumb_url= wp_get_attachment_image_src( $img_id, $size );
            $thumbnails[] = $thumb_url;
            $output .= "<div class='item";
            if( $i == 0 ) {
                $output .= ' active';
                $i++;
            }
            $image = get_post( $img_id );
            $output .= "'>";
            $output .= "<img src='".$full_url[0]."' />";
            $output .= "<div class=\"carousel-caption\">".
                            "<h4>".$image->post_title."</h4>".
                            "<p>".esc_html( $image->post_excerpt )."</p>".
                       "</div>";
            $output .= "</div>";
        }
        $output .= " </div>";
        $a = 1;
        $catt = count($attachments);
        $output .= ' <ol class="carousel-indicators">';
        $output .= "<li data-target='#dgallery-{$id}{$gid}' data-slide-to='0' class='active'></li>";
        while( $a < $catt ) {
            $output .= "<li data-target='#dgallery-{$id}{$gid}' data-slide-to=".$a."></li>";
            $a++;       
        }
        $output .= '</ol>';
        $output .= '<a class="carousel-control left" href="#gallery-'.$id.$gid.'" data-slide="prev"><i class="icon-chevron-left"></i></a>
        <a class="carousel-control right" href="#gallery-'.$id.$gid.'" data-slide="next"><i class="icon-chevron-right"></i></a>';
        $output .= "</div>";
        return $output;
    }
    remove_shortcode('gallery', 'gallery_shortcode');
    add_shortcode('gallery', 'dw_gallery_shortcode');
}

Hope this helps !

Powered by DW Question & Answer Pro