Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter nbruley

    (@nbruley)

    I tried $image->href and this almost works, but it adds in the whole thumbnail and everything, and I just want a link to the picture.

    In another post I see referenced a method to access the database

    <?php $album = nggdb::find_album( get_query_var('album') ); ?>

    Does anyone know the function like this to get the proper data for the current image href?

    Thank you.

    I am also looking to have the ability to have a download button on the Gallery page.

    I have tried a couple of things but have had no luck.

    Thread Starter nbruley

    (@nbruley)

    If I don’t use imagebrowser I think I got it to work on the gallery page, but with imagebrowser I can’t get it yet. Oh well, at least I have it on imagebrowser for now.

    Can you please explain how you got it to work without using imagebrowser.

    Is it something that comes with NextGen gallery? or is this something that you created?

    Thread Starter nbruley

    (@nbruley)

    It involves adding some code to /wp-content/plugins/nextgen-gallery/view/gallery-caption.php (or you probably want to make your own custom theme by copying the .php file and naming it gallery-mytemplate.php and referencing [template=mytemplate]

    Here’s a snippet from my gallery-template file that includes modified code:
    [Code moderated as per the Forum Rules. Please use the pastebin]

    Then you need to upload force-download.php to your home directory.
    Code for this file is as follows:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    You’ll probably have to tweak the code to your liking. Instead of the hyperlink you can make it a button.

    I think this would work. You may have to adjust other settings in the gallery. I think you have to use the caption template, can’t remember for sure. See if it works and let me know.

    Thread Starter nbruley

    (@nbruley)

    Sorry, I edited the code above slightly. The important line is

    <!-- ADD DOWNLOAD LINK, changed image-caption to image-alttext NB ???  -->
    <span><?php echo $image->alttext ?><br /><?php echo $image->caption; ?><br /><a href=" <?php home_url(); ?> /force-download.php?file=<?php echo substr(parse_url($image->imageURL,PHP_URL_PATH),2); ?> ">Download</a></span>

    I tested without imagebrowser and it works on my settings.

    Thread Starter nbruley

    (@nbruley)

    Another note: the “2” in the following code may need to be “1” depending on how the location of the gallery images is entered in the gallery configuration page. If it begins with a “/” you’ll need a 2 to eliminate it, if it begins with a folder name, you need a 1.
    substr(parse_url($image->imageURL,PHP_URL_PATH),2);

    Thread Starter nbruley

    (@nbruley)

    UPDATE: I decided to forget about imagebrowser and just use the shutter style, so the links in the first post no longer demonstrate the problem.

    Hi nbruley – I’ve been searching and searching for a solution like the one you are describing. Could you re-post the PHP that has been moderated out?

    Many thanks!

    Thread Starter nbruley

    (@nbruley)

    Force download code (images/audio):
    https://pastebin.com/c7RxpsPP

    my NextGEN template file (complete)
    https://pastebin.com/Z709fu0f

    Hope that helps.

    The Gal

    (@peterpevensie)

    Sir, you are a genius. I just used your code as well and it worked so well, I quite literally exclaimed aloud with joy. ?? THANK YOU for sharing your work!!!

    nbruley – fantastic! Worked like a dream.

    Many thanks.

    This looks like what I’m trying to do butI’m not using either of these galleries. I have a single image in each of my WP posts and want to add a link within the post (located in on single.php file) to download that image (ideally, I’ll configure it to display 3 links to allow users to download a large, medium, or small image).

    Is this possible with what you have here?
    Thanks!

    Thread Starter nbruley

    (@nbruley)

    ernaparalla, yes, this should work. If I understand you correctly, you would use only the force-download.php file and create a link to download a specific file using a URL like
    mySite.com/force-download.php?file=small/myFile.jpg
    mySite.com/force-download.php?file=medium/myFile.jpg
    mySite.com/force-download.php?file=large/myFile.jpg

    In your case, you may wish to put the different sized images in different folders and call them by the same file name. This might simplify the php coding.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘[Plugin: NextGEN Gallery] Adding a download link/button’ is closed to new replies.