• htmltiger

    (@htmltiger)


    https://www.mediafire.com/?dsj1h8ispp2uq4a
    or modify paginated-gallery.php

    <?php
    /*
    Plugin Name: Paginated Gallery
    Plugin URI: https://www.phil-barker.com/*page here*
    Description: Adds pages to the wordpress gallery
    Version: 0.2
    Author: Phil Barker
    Author URI: https://www.phil-barker.com
    License: GPL2
    */
    
    /*  Copyright 2011  Phil Barker  (email : [email protected])
    
        This program is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License, version 2, as
        published by the Free Software Foundation.
    
        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.
    
        You should have received a copy of the GNU General Public License
        along with this program; if not, write to the Free Software
        Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    */
    
    require_once(dirname(__FILE__) . '/options.php');
    
    if (get_option('use_gallery_shortcode')) {
    	// Over-ride the standard gallery shortcode with our own
    	remove_shortcode('gallery');
    	add_shortcode('gallery', 'paginated_gallery');
    } else {
    	add_shortcode('paginated-gallery', 'paginated_gallery');
    }
    
    function paginated_gallery($attr) {
    	/* Outputs a gallery of attachments with pagination
    	Most of this code is lifted from the standard gallery function - with a few tweeks for pagination
    	*/
    	$post = get_post();
    
    	static $instance = 0;
    	$instance++;
    
    	if ( ! empty( $attr['ids'] ) ) {
    		// 'ids' is explicitly ordered, unless you specify otherwise.
    		if ( empty( $attr['orderby'] ) )
    			$attr['orderby'] = 'post__in';
    		$attr['include'] = $attr['ids'];
    	}
    
    	// Allow plugins/themes to override the default gallery template.
    	$output = apply_filters('post_gallery', '', $attr);
    	if ( $output != '' )
    		return $output;
    
    	// We're trusting author input, so let's at least make sure it looks like a valid orderby statement
    	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 ? $post->ID : 0,
    		'itemtag'    => 'dl',
    		'icontag'    => 'dt',
    		'captiontag' => 'dd',
    		'columns'    => 3,
    		'size'       => 'thumbnail',
    		'include'    => '',
    		'exclude'    => '',
    		'link'       => 'file'
    	), $attr, 'gallery'));
    
    	$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);
    	$icontag = tag_escape($icontag);
    	$valid_tags = wp_kses_allowed_html( 'post' );
    	if ( ! isset( $valid_tags[ $itemtag ] ) )
    		$itemtag = 'dl';
    	if ( ! isset( $valid_tags[ $captiontag ] ) )
    		$captiontag = 'dd';
    	if ( ! isset( $valid_tags[ $icontag ] ) )
    		$icontag = 'dt';
    
    	$columns = intval($columns);
    	$itemwidth = $columns > 0 ? floor(100/$columns) : 100;
    	$float = is_rtl() ? 'right' : 'left';
    
    	$selector = "gallery-{$instance}";
    
    	$gallery_style = $gallery_div = '';
    	if ( apply_filters( 'use_default_gallery_style', true ) )
    		$gallery_style = "
    		<style type='text/css'>
    			#{$selector} {
    				margin: auto;
    			}
    			#{$selector} .gallery-item {
    				float: {$float};
    				margin-top: 10px;
    				text-align: center;
    				width: {$itemwidth}%;
    			}
    			#{$selector} img {
    				border: 2px solid #cfcfcf;
    			}
    			#{$selector} .gallery-caption {
    				margin-left: 0;
    			}
    			/* see gallery_shortcode() in wp-includes/media.php */
    		</style>";
    	$size_class = sanitize_html_class( $size );
    	$gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
    	$output = apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div );
    
    	$i = 0;
    
    	// Standard post output
    	$imagesPerPage = get_option('thumbnails_per_page');
    
    	// Work out how many pages we need and what page we are currently on
    	$imageCount = count($attachments);
    	$pageCount = ceil($imageCount / $imagesPerPage);
    
    	$currentPage = intval($_GET['galleryPage']);
    	if ( empty($currentPage) || $currentPage<=0 ) $currentPage=1;
    
    	$maxImage = $currentPage * $imagesPerPage;
    	$minImage = ($currentPage-1) * $imagesPerPage;
    
    	if ($pageCount > 1)
    	{
    		$page_link= get_permalink();
    		$page_link_perma= true;
    		if ( strpos($page_link, '?')!==false )
    			$page_link_perma= false;
    
    		$gplist= '<div class="gallery_pages_list">'.__('Pages').'&nbsp; ';
    		for ( $j=1; $j<= $pageCount; $j++)
    		{
    			if ( $j==$currentPage )
    				$gplist .= '[<strong class="current_gallery_page_num"> '.$j.' </strong>]&nbsp; ';
    			else
    				$gplist .= '[ <a href="'.$page_link. ( ($page_link_perma?'?':'&') ). 'galleryPage='.$j.'">'.$j.'</a> ]&nbsp; ';
    		}
    
    		$gplist .= '</div>';
    	}
    	else
    		$gplist= '';	
    
    	$k = 0;
    	foreach ( $attachments as $id => $attachment ) {
    		if ($k >= $minImage && $k < $maxImage) {
    
    		if ( ! empty( $link ) && 'file' === $link )
    			$image_output = wp_get_attachment_link( $id, $size, false, false );
    		elseif ( ! empty( $link ) && 'none' === $link )
    			$image_output = wp_get_attachment_image( $id, $size, false );
    		else
    			$image_output = wp_get_attachment_link( $id, $size, true, false );
    
    		$image_meta  = wp_get_attachment_metadata( $id );
    
    		$orientation = '';
    		if ( isset( $image_meta['height'], $image_meta['width'] ) )
    			$orientation = ( $image_meta['height'] > $image_meta['width'] ) ? 'portrait' : 'landscape';
    
    		$output .= "<{$itemtag} class='gallery-item'>";
    		$output .= "
    			<{$icontag} class='gallery-icon {$orientation}'>
    				$image_output
    			</{$icontag}>";
    		if ( $captiontag && trim($attachment->post_excerpt) ) {
    			$output .= "
    				<{$captiontag} class='wp-caption-text gallery-caption'>
    				" . wptexturize($attachment->post_excerpt) . "
    				</{$captiontag}>";
    		}
    		$output .= "</{$itemtag}>";
    		if ( $columns > 0 && ++$i % $columns == 0 )
    			$output .= '<br style="clear: both" />';
    		}
    		$k++;
    
    	}
    
    	$output .= "
    			<br style='clear: both;' />$gplist
    		</div>\n";
    
    	return $output;
    
    }
    
    ?>

    https://www.ads-software.com/plugins/paginated-gallery/

Viewing 2 replies - 1 through 2 (of 2 total)
  • hey mate, this works also in WP 3.9.1, thank you.

    but it replaces jetpack’s tiled gallery with the standard thumbnail one.

    does anyone know how to get this working with a jetpack tiled gallery?

    Amazing plugin man! Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Updated for wordpress 3.7’ is closed to new replies.