printdownloadLink for image download

Hi. I'm trying to add a download link to the current image, ie. the image being viewed. I tried inserting the following line into my theme's image.php but it appears to download a link and not a jpeg image as I'm expecting.

<?php printdownloadLink($_zp_current_image->getFullImageURL()) ?>

Also, how can I modify this to print the word 'download' instead of the image name? Thank you!

What I'd like to do is have a 'Download' button that will download the current image.

Comments

  • The second parameter (optional) to the function is the link text. Always a good idea to look at the function documentation for functions you wish to use.

    The function will output an href. But you can turn that into a button by appropriate CSS. E.g. add a `... around the function call output and in your CSS define the css for`mybutton`. A good starting point would be the`buttons` css class in one of the distributed themes.
  • Yes, the documentation says:

    printDownloadLink(path-to-file);.

    What parameter can I use for 'path-to-file' that will pass the current image to the function and produce a jpeg image?
  • acrylian Administrator, Developer
    Yes, the documentation says:
    printDownloadLink(path-to-file);.
    Not sure where you looked but the documentation does note the 2nd parameter as my colleague said above:
    http://www.zenphoto.org/documentation/plugins/tools/_zp-extensions---downloadList.php.html#functionprintDownloadLink
    hat parameter can I use for 'path-to-file' that will pass the current image to the function and produce a jpeg image?
    As you did it will get the full image.
  • Okay, I'll spell it out. The line (from above):
    <?php printdownloadLink($_zp_current_image->getFullImageURL()) ?>

    is producing:
    Warning: filesize() [function.filesize]: stat failed for /photography/albums/all/avocado_awesomeness.jpg in /home/user/public_html/photography/zp-core/zp-extensions/downloadList.php on line 496
    avocado_awesomeness.jpg (0 Bytes) - 0 downloads

    The line:
    <?php printdownloadLink(getFullImageURL()) ?>

    is producing:
    photography (4 kB) - 3 downloads

    When I click this link a blank unknown document is downloaded, not a photo.

    What else can I try? Thank you.
  • acrylian Administrator, Developer
    `$_zp_current_image->getFullImageURL()` is actually wrong. The method to use is named `getFullImage()`. So it can't work. You should have had an error in the server error log about that. A fatal one actually.

    As to the 2nd you should also look into your server error log.
  • Still not working.

    <?php printdownloadLink(getFullImage()) ?>

    is producing:

    Fatal error: Call to undefined function getFullImage() in /home/user/public_html/photography/themes/zpmasonry/image.php on line 69

    What else?
  • acrylian Administrator, Developer
    Yes, of course. You really need to read what we tell and look at the documentation
    `$_zp_current_image->getFullImage()` (object model way)
    OR
    `getFullImageURL()` (template function way - if you use this be sure not to protect the full image url - use getUnprotectedImageURL() in that case)
    gets the url to the full image in single image context.
  • Sorry, I'm giving up. None of the code you have given me has produced a jpeg image. I'm getting warning messages and empty files.

    <?php printdownloadLink($_zp_current_image->getFullImage() ) ?>

    <?php printdownloadLink(getFullImageURL()) ?>

    <?php printdownloadLink(getUnprotectedImageURL() ) ?>
  • acrylian Administrator, Developer
    You need to look at your server access and error log to find anything related and make sure the image is accessible (file permissions)
Sign In or Register to comment.