ZenphotoCMS Forum
printdownloadLink for image download - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: Plugins (https://forum.zenphoto.org/forum-6.html)
+--- Thread: printdownloadLink for image download (/thread-11262.html)



printdownloadLink for image download - jeronimo42 - 12-08-2013

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.

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.




printdownloadLink for image download - sbillard - 12-08-2013

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 formybutton. A good starting point would be thebuttons` css class in one of the distributed themes.




printdownloadLink for image download - jeronimo42 - 12-08-2013

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?




printdownloadLink for image download - acrylian - 12-08-2013

Quote: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

Quote: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.




printdownloadLink for image download - jeronimo42 - 12-08-2013

Okay, I'll spell it out. The line (from above):

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:

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.




printdownloadLink for image download - acrylian - 12-08-2013

$_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.




printdownloadLink for image download - jeronimo42 - 13-08-2013

Still not working.

is producing:

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

What else?




printdownloadLink for image download - acrylian - 13-08-2013

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.




printdownloadLink for image download - jeronimo42 - 13-08-2013

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.




printdownloadLink for image download - acrylian - 13-08-2013

You need to look at your server access and error log to find anything related and make sure the image is accessible (file permissions)