Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • That happens because most of this plugin is a copy of ,
    IMAGE GALLERY RELOADED.
    Author says its a fork but if you make a diff …

    So when you click Plugins-> Responsive Media Gallery-> Settings , it takes you to this url:

    wp-admin/options-general.php?page=image-gallery-reloaded/image-gallery-reloaded.php

    One of the parts that has been removed when “forking”, is the part that actually makes admin options work. So my advice is to install IMAGE GALLERY RELOADED instead

    It′s an old thread but i actually had to make some changes to code to achieve this, so i′ll share for future googlers.

    With this solution images will be ordered in the order they appear in shortcode

    SOLUTION
    Search in folder wp-content/responsive-media-gallery/responsive-media-gallery.php

    In there you will find a function called “igr_gallery_shortcode”.

    1)Add ‘custom_order’ => false, to array passed to extract, around line 132.

    2) We add an if clause for using our custom order

    if( $custom_order ){
    			foreach( explode("," , $ids)  as $id_img  )
    			{
    				$attachments[$id_img] = $_attachments[$id_img];
    			}	
    
    		}else{
    
    			foreach ( $_attachments as $key => $val )
    			{
    				$attachments[$val->ID] = $_attachments[$key];
    			}
    
    		}

    You will end up with something like this:

    function igr_gallery_shortcode($attr)
    {
    	global $post;
    	$options = get_option('igr_options');
    
    	if (isset($attr['orderby']))
    	{
    		$attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
    		if ( !$attr['orderby'] )
    			unset( $attr['orderby'] );
    	}
    
    	extract(shortcode_atts(array(
    		'orderby'		=> 'menu_order ASC, ID ASC',
    		'id'			=> $post->ID,
    		'itemtag'		=> 'dl',
    		'icontag'		=> 'dt',
    		'captiontag'	=> 'dd',
    		'columns'		=> 3,
    		'size'			=> 'thumbnail',
    		'include'		=> '',
    		'ids'			=> '',
    		'custom_order'	        => false //parameter added
    	), $attr));
    
        $count = 1;
    	$id = intval($id);
    
    	if(!empty($ids))
    	{
    		$ids = preg_replace( '/[^0-9,]+/', '', $ids );
    		$_attachments = get_posts( array(
    										'include'			=> $ids,
    										'post_type'			=> 'attachment',
    										'post_mime_type'	=> 'image',
    										'orderby'			=> $orderby
    										)
    								  );
    		$attachments = array();
    
                 //Select if we want to order images like its declared in shortcode
    
    		if( $custom_order ){
    			foreach( explode("," , $ids)  as $id_img  )
    			{
    				$attachments[$id_img] = $_attachments[$id_img];
    			}	
    
    		}else{
    
    			foreach ( $_attachments as $key => $val )
    			{
    				$attachments[$val->ID] = $_attachments[$key];
    			}
    
    		}
    
    //thats all the rest of the function remains the same

    Now you can use shortcode in this way:

    [gallery ids="576,579,571,572,573,574,578,575,577,580" orderby="none" custom_order="true"]'
Viewing 2 replies - 1 through 2 (of 2 total)