I need to offer a zip file download [to registered users] on every post, containing all the images attached to the post. The solution provided in this thread works well for the purpose, although it did not work in old version of PHP 5.2 due to a namespace syntax in the first line of the plugin code - namespace GalleryZip;.

I tested the plugin offered in the thread on my localhost with wordpress 3.6.1 installed with this line of code in single.php <?php echo do_shortcode('[gallery]'); ?> which offers a nice zip-download link 'Get as Zip', so far so good. But, now when I installed the same plugin on my live site which also runs on latest wp 3.6.1 it displayed a link as expected but the link does not prompt a zip-download and when clicked just refreshes the page. Earlier the plugin also displayed an unexpected native gallery of the images attached to post which was promptly solved by @cybnat.

ENVIRONMENT : My live site uses PHP 5.3.27 and localhost is a WAMP on windows 7 and uses PHP 5.3.1. I have tested in latest firefox, chrome and safari browsers, works as expected on localhost and not on live site. I changed the theme into default twenty-thirteen ( tried it inside and outside the loop ) and also disabled all the other plugins, no change in result. Firebug console displays http://website.com/wp-admin/admin-ajax.php 200 OK on clicking the link. In the view source of live site js is loaded as expected, here is the print.

<script type='text/javascript' src='http://website.com/wp-content/plugins/gallery-zip-master/js/gallery_zip.min.js?ver=3.6.1'></script>

UPDATE : Following an advice below I upgraded my localhost wp install to 3.6.1 and have ruled out the possibility of any issue due to a difference in wp versions. The plugin still works as expected and offers a zip download link on click while tested in local environment. The issue that remains is that on live server the link does not prompt a zip-download instead just refreshes the page. Although I am continuously testing and in every way I can, a little help or a hint would be greatly appreciated.

**Title and content of the question are being adjusted in accordance to latest feedbacks and situation. If you may, kindly take a look at the plugin code at github and let me know if this could be solved or correct me if I am wrong anywhere. Also let me know if you feel that the question should be asked in some other forum.

  • 1
    I don't think you can assume that the problem is related to a core difference between 3.6 and 3.6.1. It is more likely to be a difference in server configuration between your local environment and your live web server. To test, update your local to 3.6.1 (or roll back your live site to 3.6) and see if the situation changes. – Ben Miller - Remember Monica Sep 19 '13 at 17:28
  • Right, I will just upgrade the local site and see how it goes. – gurung Sep 19 '13 at 17:37
  • You might want to change the title of this question, as has nothing to do with 3.6 vs 3.6.1. – Ben Miller - Remember Monica Sep 19 '13 at 19:03
  • Just to let you know, I am seeing the same problem: I can get it to work on my local environment (XAMPP), but not on my hosted web server. – Ben Miller - Remember Monica Sep 19 '13 at 19:23
  • To eliminate another possibility: It does not appear to be a PHP 5.3 vs 5.4 thing, either. At first, I thought it was possible, since I was using 5.4 locally and 5.3 on my website, but I've updated the website to 5.4 and eliminated that possibility. – Ben Miller - Remember Monica Sep 19 '13 at 19:41

As you can see, the code of the linked question add a custom gallery shortcode in this function:

private final function __construct() {
    remove_shortcode( 'gallery' );
    add_shortcode( 'gallery', array( __CLASS__, 'gallery_zip_shortcode' ) );

and then this custom gallery shortcode is executed in this function:

public static function gallery_zip_shortcode( $atts ) {

    $post = get_post();

    if ( ! function_exists( 'gallery_shortcode' ) )
        require_once ABSPATH . 'wp-includes/media.php';

    self::get_gallery_images_from_shortcode( $post->ID, $atts );
    $output = gallery_shortcode( $atts );

    $gallery_id = count( self::$images[$post->ID] ) - 1;

    $link = sprintf( '<div><a href="#" gallery-id="%d" post-id="%d" class="gallery-zip">%s</a></div>', $gallery_id, $post->ID, __( 'Get as Zip' ) );
    $output .= $link;

    return $output;


Try to comment out the $output = gallery_shortcode( $atts ); line.

The other issue (which you forgot to mention in your question) about the download link not working is because the plugin can have unexpected behavior, as it actullay is, for Wordpress < 3.5. You should contact the developer.

| improve this answer | |
  • Thank you for the prompt response and my apologies to have forgotten to have mentioned more important issue, which is that the link when clicked only refreshes the page and does not offer a zip download in 3.6.1. I have corrected my question. As told I have commented out the said line which takes care of the unwanted gallery but the main issue remains the same. – gurung Sep 19 '13 at 16:31
  • Ahh, so the main issue is the one you forgot to mention...Funny!!! – cybmeta Sep 19 '13 at 17:13
  • sorry about that again, it does not seem to be an issue with js though as I can see the script loaded in the view source. – gurung Sep 19 '13 at 17:46
  • the click on the download link must fire the javascript and ajax request to download the zip file. Look at the console log of your browser when you click the link. – cybmeta Sep 19 '13 at 17:48
  • In the firebug console.It shows. http://website.com/wp-admin/admin-ajax.php 200 OK and in the view source <script type='text/javascript' src='http://website.com/wp-content/plugins/gallery-zip-master/js/gallery_zip.js?ver=3.6.1'></script> – gurung Sep 19 '13 at 18:02

Directory permission was an issue regarding this topic. As the plugin is activated it creates a folder named "galleryzip-cache" under the directory wp-content. The folder has it's permission set to 001 on its initial creation. If you set the permission to 775, it will work flawless.

All the credits and efforts goes to @cybnet and @benmiller who actually tried to answer. Leaving an answer made more sense to me than leaving a comment which is pretty obscure in comparision. Hope this helps someone.

| improve this answer | |

After many research I found that the problem is with the directory galleryzip-cache generated form the plugin. the you have to modify the right access to the folder galleryzip-cache at 755 and all works fine.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.