WordPress.org

Ready to get started?Download WordPress

Forums

NextGEN Download Gallery
Linking to high res images using NextGen 2.0 pro albums (7 posts)

  1. mellowvision
    Member
    Posted 10 months ago #

    I apologize for chiming in in the other thread, this seemed closely related to the topics I saw being discussed there.

    Here is my issue:
    I need to force the download of the original high res image. I have already installed and configured NextGen 2.0, and have tried several approaches to creating a download link.

    So far, the closest I've come to making this work the way I'd like is by using a force-download.php in the root, and editing the nextgen_pro_thumbnail_grid.php file manually. This is a poor solution in two ways: it will be destroyed if I upgrade the plugin, and it exposes the force-download.php script to malicious users.

    Since NextGen 2.0 doesn't come equipped to handle templates for pro features, I'm having trouble implementing this in an updatable way.

    I tried several other plugins as well including Force Download Shortcode and Force Images Download. Neither worked correctly out of the box with my situation.

    So, I found your plugin, and like what it's potential, but I can not implement it because NextGen doesn't handle templates for the pro albums and galleries.

    Is there a way to work around this? can I call the forced download from the php in nextgen_pro_thumbnail_grid.php? I realize this is only half a solution since I won't be able to update the plugin, but I'm under the gun and need a solution as soon as possible to keep my client sane.

    The two pieces of code I had tried out in the php were:
    <a href="<?php echo esc_attr($storage->get_image_url($image))?>" class="forceDownload">Download</a> (called the forced download, but resulted in the homepage instead of the file)

    and

    <a href=" <?php home_url(); ?> /force-download.php?file=<?php echo esc_attr($storage->get_image_url($image))?> ">Download</a> (called the exposed php file, but the php didn't expect a full image url with http: so it failed.. could be fixed easily, but still poses a security risk)

    It would be great to be able to do something similar, until nextgen includes template capability for pro albums, or until there is a better solution.

    http://wordpress.org/plugins/nextgen-download-gallery/

  2. webaware
    Member
    Plugin Author

    Posted 10 months ago #

    G'day mellowvision,

    If you want to let people download a single hires image by clicking a link under a thumbnail, I recommend you create a simple AJAX function that forces a download of the selected image, and link to that AJAX request in your gallery template. e.g.

    <?php
    $args = array('action' => 'download-ngg-hires', 'id' => $image->pid);
    $url = add_query_arg($args, admin_url('admin-ajax.php'));
    ?>
    <a href="<?php echo $url; ?>">Download</a>

    Take a look at the AJAX handler function in my plugin, and read about adding AJAX to plugins.

    If you just want to make my plugin work with gallery templates within albums, link the galleries to pages that use the nggallery shortcode and specify template=download in the shortcode.

    cheers,
    Ross

  3. mellowvision
    Member
    Posted 10 months ago #

    Hi Ross,

    Thanks for the feedback. I've also heard back from nextgen, who suggests just not using the pro templates or waiting for future releases. I didn't want to have to step down from the pro features, but since I need both captions and the download link, it looks like it might be the simplest solution at this point. At least I'll be able to use templates and your plugin(Ithink).

    Thanks for providing and maintaining this plugin. Much appreciated.

  4. mellowvision
    Member
    Posted 10 months ago #

    Hi Ross,

    I think I'm close to a solution.

    Unfortunately, I can't make pages for all the galleries. I am making only a page that houses the album shortcode, using

    [ngg_images album_ids="1" display_type="photocrati-nextgen_basic_extended_album"]

    This then generates the galleries deeper in.

    So, I've specified that the basic extended album will have Basic Thumbnails. Then in the settings for Basic Thumbnails I've chosen an override template for the gallery.

    I then pasted in your code above. The missing link would be the actual ajax. But I guess I'm wondering if there's just a way to modify the code you provided above to call your plugin into action? or use your handler?

    That seems like the most direct approach to me, instead of writing another handler.

  5. mellowvision
    Member
    Posted 10 months ago #

    What I ended up doing here was using the Download Shortcode plugin and using do_shortcode in a custom gallery override template.

    Getting this to work took a few steps.

    1. in the nextgen settings, be sure to store your images and galleries in the uploads folder. This is required for the Download Shortcode plugin

    2. create your own custom template for the nextgen gallery, and get that operating

    3. insert the a download link into that template using do_shortcode to trigger the Download Shortcode plugin. My code looked like this:

    <?php echo do_shortcode( "[download label='Download'] $image->imageURL [/download]" ); ?>

    *big note:
    I had about 4 galleries set up and displaying in a single album before I tried this approach. It did not seem to work at first, I think because the images were not originally uploaded within the uploads folder. Changing the nextgen preferences to store images and galleries in uploads did NOT correct the issue for OLD galleries. Any NEW galleries that were created after the change all operated correctly with the Force Download call. So, you should either make all the settings changes first, or be prepared to reupload all your old galleries to make the download links work.

  6. webaware
    Member
    Plugin Author

    Posted 10 months ago #

    @mellowvision: well done. Sounds like quite the journey, but you got there! It shouldn't be this hard, really, but I guess NextGEN Gallery just isn't made for it. You could probably get it going with a custom display type in NGG2, but that's a whole nuther kettle of fish.

    And I'm really going to have to get a wriggle on with my pro plugin, because it sounds like there's a need for it!

    cheers,
    Ross

  7. mellowvision
    Member
    Posted 8 months ago #

    thanks Ross

Reply

You must log in to post.

About this Plugin

About this Topic