phantomeye Posted February 15, 2011 Share Posted February 15, 2011 Hi Guys,I would like to give my customers the ability to download the product image, without having to right click and save image as. Can you tell me how i can do this. I would like to put a line under the product image that says, "Download image here" when they click, it gives them the option to save the image.I was going to upload all my images as zips into the download folder, but was wondering if there was a simpler method to download the image directly from the image directory.Thanks Link to comment Share on other sites More sharing options...
MrBaseball34 Posted February 18, 2011 Share Posted February 18, 2011 This should get you started. <?php if(!empty($_GET['img'])) { $filename = $_GET['img']; $size = @getimagesize($filename); $fp = @fopen($filename, "rb"); if ($size && $fp) { // header("Content-type: {$size['mime']}"); header("Content-Type: application/octet-stream"); header("Content-Length: " . filesize($filename)); header("Content-Disposition: attachment; filename=$filename"); header('Content-Transfer-Encoding: binary'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); fpassthru($fp); exit; } } header("HTTP/1.0 404 Not Found"); ?> Link to comment Share on other sites More sharing options...
phantomeye Posted February 26, 2011 Author Share Posted February 26, 2011 Hi Mr Baseball,Apologies for not responding earlier, for some reason, i did not receive notification on this post. Thanks once again for your help, this maybe a stupid question, where should i insert this code. I have a button that i have inserted in the pb-left column block in product.tpl Link to comment Share on other sites More sharing options...
MrBaseball34 Posted February 27, 2011 Share Posted February 27, 2011 You can also have a link just below the product image where Print and View large Image is in product.tplIt is called the useful links "block"looks something like this: > <!-- usefull links--> </pre> <ul> {if $HOOK_EXTRA_LEFT}{$HOOK_EXTRA_LEFT}{/if} {l s='Print'} {if $have_image && !$jqZoomEnabled} {l s='View full size'} {/if} </ul> Then take the code I posted, put it in another php file, place it in your web root and call it like download_image.phpthen the link would be made up like this: getImageLink($product->link_rewrite, $imageIds, 'large')}">{l s='Download Image'} This should help you finish everything up. This should retrieve the large format image of the product.If it doesn't put the correct img parameter, play around with the vaules in product.tpl to get the right one. Link to comment Share on other sites More sharing options...
phantomeye Posted February 28, 2011 Author Share Posted February 28, 2011 Thanks Mr Baseball, will give it a go today and get back to you. Okay, give it a try and nothing happened. If it makes a difference, i am using PS1.4 Heres what i did:1) Created download_image.php file in my home directory2) Edited the product.tpl file and added the line you indicatedLet me know which step am i skipping (probably linking product.tpl to download_image.phpCheers Link to comment Share on other sites More sharing options...
markmorales Posted August 19, 2014 Share Posted August 19, 2014 can you provide a source code how did you do this?please. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now