最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

gallery - zip download plugin works well in localhost but not on live site

programmeradmin0浏览0评论

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 .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='.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.

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/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/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.

Share Improve this question edited Apr 13, 2017 at 12:37 CommunityBot 1 asked Sep 19, 2013 at 16:02 gurunggurung 4821 gold badge17 silver badges41 bronze badges 7
  • 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 Commented Sep 19, 2013 at 17:28
  • Right, I will just upgrade the local site and see how it goes. – gurung Commented Sep 19, 2013 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 Commented Sep 19, 2013 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 Commented Sep 19, 2013 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 Commented Sep 19, 2013 at 19:41
 |  Show 2 more comments

3 Answers 3

Reset to default 1

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.

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.

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.

发布评论

评论列表(0)

  1. 暂无评论