4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: skink on September 13, 2002, 09:00:13 AM

Title: Different download options / Verschiedene Download Möglichkeiten
Post by: skink on September 13, 2002, 09:00:13 AM
Hi,

I'm planning to use 4images for an online image licensing system. The licenses and the pricing will be dependent on the resolution and the size of the images. Not all images will have a fitting license option. That means for my system I'll need 3 different download options (72dpi, 150dpi & 300dpi) and 3 different buttons showing the availability of the license.

The license types will be save in different directories (eg t1=72dpi, t2=150dpi, t3=300dpi). The download buttons will be shown in the detail.php.

What I need is a modified routine of download.php which does the following

1) checks to see if the user is logged in, if not shows the download button without a link (just like it already does by the standard version)

2) checks to see if the license type is available (what it actually does is looks up in the fitting directory to see if the file exists), if not shows a special download button (not available) without a link

I know this routine is simple for someone whos firm in php. Can anyone give me a hint how to do this?

Thanks in advance.
Steve
Title: Different download options / Verschiedene Download Möglichke
Post by: Jan on September 13, 2002, 09:47:34 AM
One question: Should point the download button for the 72dpi-image to the same file who is displayed on the details page?

Jan
Title: Different download options / Verschiedene Download Möglichke
Post by: skink on September 13, 2002, 10:41:59 AM
Hi Jan,

No the download buttons should point to the same files in the appropriate directory. That means if there is a file (72dpi image) to download in the directory t1, then this file should be downloaded. The same goes for the files in the directories t2 (150dpi images) and t3 (300 dpi images). The files will all have the same name, just like the pic and thumbnail files. I figure that way, it will be easier.

Steve
Title: Different download options / Verschiedene Download Möglichke
Post by: Jan on September 13, 2002, 10:47:53 AM
Ok, i just wanted to know if you want to add 3 new download buttons or only two, because you use the default button for 72dpi-downloads. Just give a little bit time, i will see what i can do.

Jan
Title: Different download options / Verschiedene Download Möglichke
Post by: skink on September 13, 2002, 12:01:24 PM
No problem!

Thanks again for taking your time.

Steve
Title: Different download options / Verschiedene Download Möglichke
Post by: Jan on September 13, 2002, 01:39:49 PM
Ok, try this:

Open "includes/functions.php" and add after:
Code: [Select]
   $allow_download = 1;
  }

this:
Code: [Select]
 $additional_download_sizes = array(72, 150, 300);

  $register_array = array();
  foreach ($additional_download_sizes as $size) {
    ereg("(.+)\.(.+)", basename($image_row['image_media_file']), $regs);
    $file = ((is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/" : MEDIA_PATH."/".$image_row['cat_id']."/").$regs[1]."_".$size.".".$regs[2];
    if (!$allow_download || !get_file_path($file, "media", $image_row['cat_id'], 0, 0)) {
      $register_array['download_button_'.$size] = "<img src=\"".get_gallery_image("download_off.gif")."\" border=\"0\" alt=\"\" />";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<img src=\"".get_gallery_image("download_zip_off.gif")."\" border=\"0\" alt=\"\" />" : "";
    }
    else {
      $register_array['download_button_'.$size] = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size=".$size)."\"".$target."><img src=\"".get_gallery_image("download.gif")."\" border=\"0\" alt=\"\" /></a>";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=zip&amp;".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size=".$size)."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>" : "";
    }
  }
  $site_template->register_vars($register_array);


You can add more sizes to $additional_download_sizes.
Now you can use in the template details.html the following tags:
Code: [Select]
{download_button_72}
{download_zip_button_72}

{download_button_150}
{download_zip_button_150}

{download_button_300
{download_zip_button_300}

Greets Jan
Title: Different download options / Verschiedene Download Möglichke
Post by: skink on September 13, 2002, 05:37:43 PM
Hi Jan,

I've implemented it into functions.php and the template details.html.

Heres are couple of questions just to see if I understand the code properly.

The files are found in the directory ../4images/data/media/categorie_id/. Is that right?

The name of the file will be like picture_72.jpg and picture_150.jpg and so forth. Am I on the right track?

Steve
Title: Different download options / Verschiedene Download Möglichke
Post by: Jan on September 13, 2002, 05:56:51 PM
Uhh, sorry. I forgot to explain this. Yes, you are right.

Jan
Title: Different download options / Verschiedene Download Möglichke
Post by: skink on September 13, 2002, 06:35:19 PM
Thanks very much Jan. It works great  :D
Title: Different download options / Verschiedene Download Möglichke
Post by: skink on September 23, 2002, 12:36:08 AM
Hi Jan,

I've just noticed that there is one mistake that happens with the script you posted. If a user is not registered, then no buttons are shown at all. I'd prefare it when guests would be able to see the buttons which show the availablity of the licenses. The buttons should be shown in the blured way they usually do, when there is no link behind them. This would be a great marketing option which would give unregistered users a reason to register.

Can you give me a hint on this one?

Thanks again for your great help.

Steve
Title: Different download options / Verschiedene Download Möglichke
Post by: Jan on September 23, 2002, 10:01:43 AM
I don't know if i have understand your question correctly. But i think th code should work in the way you want. If there is no file available OR the user has not the permission to download, the button should be shown in the blured way. Are you sure that they do not?

Jan
Title: Different download options / Verschiedene Download Möglichke
Post by: skink on September 23, 2002, 10:40:09 AM
Hi Jan,

Well the script works fine, when the user ist logged on and there is no file available OR the user does not have the permission to download. As soon as they are logged off and have guest status no buttons are shown at all.

I tried to find the mistake, but my php skills are'nt good enough.  :cry:

Steve
Title: Different download options / Verschiedene Download Möglichke
Post by: Jan on September 23, 2002, 10:43:58 AM
I tested it, for me it works. Can you give me a URL?

Jan
Title: Different download options / Verschiedene Download Möglichke
Post by: Jan on September 23, 2002, 03:30:04 PM
Strange, can you send me your functions.php with the modifications.

Jan

P.S.: Ich brech' mir hier einen auf englisch ab und Deine Site ist auf deutsch ;)
Title: Different download options / Verschiedene Download Möglichke
Post by: Jan on September 23, 2002, 11:45:36 PM
You haven't inserted the code on the right place. Please note the } in my posting above:
Code: [Select]
 $allow_download = 1;
}

Please paste the code behind this!

Jan
Title: Different download options / Verschiedene Download Möglichke
Post by: skink on September 24, 2002, 07:50:36 AM
oops, maybe I should think it over about wearing my glasses  :oops:

I've got one question to go. How do you get the buttons to look blurred? I mean which option do you use with photoshop (in case you use that programm at all)?

Thanks again for your help and patience with dummies like me. ;-)

Steve
Title: Different download options / Verschiedene Download Möglichke
Post by: Jan on September 24, 2002, 08:43:16 AM
Open the normal button in Photoshop, duplicate the background layer, fill the background layer with white and set the transparency of the duplicated layer to 50%.

Jan
Title: Different download options / Verschiedene Download Möglichke
Post by: skink on September 25, 2002, 09:03:08 AM
Hey Jan,

I'm finally getting into programming with php.  :lol:

I just modified the code you gave me with a new feature. Instead of just showing a blurred "download button" when an image is not available, it now shows a blurred "not available button".  This even works when the user has guest status.

Question: I noticed that the download statistics (control panel) doesn't work anymore with this new piece of code. Is there a work around for this?

Steve
Title: Different download options / Verschiedene Download Möglichke
Post by: Jan on September 25, 2002, 09:52:19 AM
Are you sure? Note: Admin downloads will not be counted!

Greets Jan
Title: Different download options / Verschiedene Download Möglichke
Post by: skink on September 25, 2002, 12:14:04 PM
Sorry, your right. I didn't realize that admin downloads were not counted.

Steve
Title: Different download options / Verschiedene Download Möglichke
Post by: Fox Mulder on October 07, 2002, 03:55:02 PM
I also uses this script right now but when i tried it i had 3 new download
buttons which all look the same so i changed the script a bit like this:

befor:
Code: [Select]
"<img src=\"".get_gallery_image("download_off.gif")."\" border=\"0\" alt=\"\" />"

after:
Code: [Select]
"<img src=\"".get_gallery_image("download_off_$size.gif")."\" border=\"0\" alt=\"\" />"

And this change had to be done for each "<img src...>" line. Then i
created new buttons like "download_off_75.gif", "download_75.gif",
"download_zip_off_75.gif", "download_zip_75.gif" and this for all
three resolutions. Now i have 3 different buttons for each download link.
Therefor i won't have to write a text description next to the button
because i named the buttons inside "Download 75dpi" for example. :)
Maybe someone wants to do this so i wrote it.

Ciao,
Fox
Title: Different download options / Verschiedene Download Möglichke
Post by: Kollega on November 29, 2002, 02:10:46 PM
ok - all things discussed in these topic done and running - but

when i "check new images" in the admin menue - i´m going to find all new added 'picture_150.jpg'

is it possible to exclude all images ending with *_150.jpg in /admin/checkimages.php - so my pictures are only with "normal" names checked & listed in the Database?

att all - great script! take care
Title: Different download options / Verschiedene Download Möglichke
Post by: Fox Mulder on November 29, 2002, 02:32:10 PM
Hmm i got the same problem when chekcking new images that i find
also the _75 and all other resolutions.
At the moment i check manually only the wanted new images when
i do a "check for new images" or i first copy the low res images in the
folder, check them in and after that i copy the high-res images in
the folder so them are not found by "check for new images".
Title: Different download options / Verschiedene Download Möglichke
Post by: Kollega on November 29, 2002, 02:56:43 PM
o.k. I see! but if u add only one new image in this categorie u are going to get the whole list for "new" images - including the _150.jpg

an easier way is to check images and then deaktivate them before adding to database! so the db have all images listed but only the low resolution is shown for the users! - isn´t it?  :?:
Title: Different download options / Verschiedene Download Möglichke
Post by: Fox Mulder on November 29, 2002, 03:17:16 PM
Hehe i think so, but i can't programm php so this had to be done by Jan.
I only do copy&paste and some minor changes to get this whole thing to
work. ;)
Title: Different download options / Verschiedene Download Möglichke
Post by: Kollega on November 29, 2002, 03:39:04 PM
@Fox Mulder

only my first post needs to be done in php
the second suggestion is already possible in V1.7 - go in admin menue - check for new images - take all images to "add images" and mark the option "deaktivate"  for the *_75.jpg ore *_150.jpg! the images will be added to ur database but will not be shown - not ur users and not you if u ckeck again in this categorie for new images!

but an exclusion in php would be the better way i think - cause u will go into trouble with the "auto image resizer"! great trouble!
have fun! 8O
Title: Different download options / Verschiedene Download Möglichke
Post by: MrWante on February 04, 2003, 12:40:43 AM
Thanx for this mod...

I have a suggestion... I am trying to mod this so that instead of having to put the same files in the same folder with a new extension, one could make a new folder called 150 or 300... (in my case for resolution, like 800 and 1024)

I have managed for it to find if there is a file with the same name in the folder, but I just can't seem to get new version of the picture from a different folder when clicking on the icon...

Still trying... but I am sadly not very good at php... yet...
Anyone else can do this??

If I succed I will post it here.... if not... well....
Title: Different download options / Verschiedene Download Möglichke
Post by: V@no on February 04, 2003, 02:16:08 AM
if anyone interesting use different folders for different size images, then here is modifyed mod:
change original mod code to this:
Code: [Select]
 $additional_download_sizes = array(72, 120, 300);

  $register_array = array();
  foreach ($additional_download_sizes as $size) {
    ereg("(.+)\.(.+)", basename($image_row['image_media_file']), $regs);
    $file = ((is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/" : MEDIA_PATH."/".$image_row['cat_id']."/").$size."/".$regs[1].".".$regs[2];
    if (!$allow_download || !get_file_path($file, "media", $image_row['cat_id'], 0, 0)) {
      $register_array['download_button_'.$size] = "<img src=\"".get_gallery_image("download_off.gif")."\" border=\"0\" alt=\"\" />";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<img src=\"".get_gallery_image("download_zip_off.gif")."\" border=\"0\" alt=\"\" />" : "";
    }
    else {
      $register_array['download_button_'.$size] = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size2=".$size."&amp;size=".$size)."\"".$target."><img src=\"".get_gallery_image("download.gif")."\" border=\"0\" alt=\"\" /></a>";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=zip&amp;".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size2=".$size."&amp;size=".$size)."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>" : "";
    }
  }
  $site_template->register_vars($register_array);

I dont know if size= also uses somewhere else, so I just add one more, size2=
so, then open download.php file.
find
Code: [Select]
 if (isset($HTTP_GET_VARS['size']) || isset($HTTP_POST_VARS['size'])) {
    $size = (isset($HTTP_GET_VARS['size'])) ? intval($HTTP_GET_VARS['size']) : intval($HTTP_POST_VARS['size']);
  }
  else {
    $size = 0;
  }
add after:
Code: [Select]
 if (isset($HTTP_GET_VARS['size2']) || isset($HTTP_POST_VARS['size2'])) {
    $size2 = (isset($HTTP_GET_VARS['size2'])) ? intval($HTTP_GET_VARS['size2']) : intval($HTTP_POST_VARS['size2']);
  }
  else {
    $size2 = 0;
  }

then find:
Code: [Select]
   $file['file_path'] = dirname($image_row['image_media_file'])."/".$file['file_name'];
change to this:
Code: [Select]
   $file['file_path'] = dirname($image_row['image_media_file'])."/".(($size2) ? $size2."/" : "").$file['file_name'];
few lines down find:
Code: [Select]
   $file['file_path'] = (is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/".$file['file_name'] : MEDIA_PATH."/".$image_row['cat_id']."/".$file['file_name'];
change to this:
Code: [Select]
   $file['file_path'] = (is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/".(($size2) ? $size2."/" : "").$file['file_name'] : MEDIA_PATH."/".$image_row['cat_id']."/".(($size2) ? $size2."/" : "").$file['file_name'];
Title: Different download options / Verschiedene Download Möglichke
Post by: Clow Read on February 06, 2003, 01:53:17 AM
interesting mod but could you help me make the same mod but without the licensing thingy and be able to use different folders for different image sizes???
Title: Different download options / Verschiedene Download Möglichke
Post by: MrWante on February 06, 2003, 02:29:54 AM
Thank you V@no, for that modification to the mod!!

With some modding of my own, I got it working the way I wanted it... though yours did most of the work...

The problem is if you want to use a folder that is not an integer, that is a whole number. That is because intval is used... So, I remover that from.... this... part

Code: [Select]
 if (isset($HTTP_GET_VARS['size2']) || isset($HTTP_POST_VARS['size2'])) {
    $size2 = (isset($HTTP_GET_VARS['size2'])) ? intval($HTTP_GET_VARS['size2']) : intval($HTTP_POST_VARS['size2']);
  }
  else {
    $size2 = 0;
  }


I changed it to...

Code: [Select]
if (isset($HTTP_GET_VARS['size2']) || isset($HTTP_POST_VARS['size2'])) {
    $size2 = (isset($HTTP_GET_VARS['size2'])) ? ($HTTP_GET_VARS['size2']) : ($HTTP_POST_VARS['size2']);
  }
  else {
    $size2 = 0;
  }


This way it doesn't matter if you use "1024" or "big" as the foldername....

The reason I wanted this is that I wanted to combine it with V@no's hack...
[Mod] Show original image in new window by clicking on image (http://www.4homepages.de/forum/viewtopic.php?t=3236&highlight=)!

In that mod there is a folder is named big and put into the same folder as the images(1,2,3,4...). In the big folder images are put that are (surprisingly) bigger (could of course use smaller too, but what would the point be) Then that image will pop up in a new window... Great mod, I got it working!

Now, I also wanted the option to have a download button for big and also maybe other sizes like 1024 and so on...

But in the big modification there is no extension _big placed after each imagename (and no reason to if you have it in a different foler)... so I had to remove some code from this one as well...

 
Code: [Select]
$additional_download_sizes = array(72, 120, 300);

  $register_array = array();
  foreach ($additional_download_sizes as $size) {
    ereg("(.+)\.(.+)", basename($image_row['image_media_file']), $regs);
    $file = ((is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/" : MEDIA_PATH."/".$image_row['cat_id']."/").$size."/".$regs[1].".".$regs[2];
    if (!$allow_download || !get_file_path($file, "media", $image_row['cat_id'], 0, 0)) {
      $register_array['download_button_'.$size] = "<img src=\"".get_gallery_image("download_off.gif")."\" border=\"0\" alt=\"\" />";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<img src=\"".get_gallery_image("download_zip_off.gif")."\" border=\"0\" alt=\"\" />" : "";
    }
    else {
      $register_array['download_button_'.$size] = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size2=".$size."&amp;size=".$size)."\"".$target."><img src=\"".get_gallery_image("download.gif")."\" border=\"0\" alt=\"\" /></a>";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=zip&amp;".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size2=".$size."&amp;size=".$size)."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>" : "";
    }
  }
  $site_template->register_vars($register_array);


this I changed to...

 
Code: [Select]
 $additional_download_sizes = array(800, 1024, 1280, 1600, big);

  $register_array = array();
  foreach ($additional_download_sizes as $size) {
    ereg("(.+)\.(.+)", basename($image_row['image_media_file']), $regs);
    $file = ((is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/" : MEDIA_PATH."/".$image_row['cat_id']."/").$size."/".$regs[1].".".$regs[2];
    if (!$allow_download || !get_file_path($file, "media", $image_row['cat_id'], 0, 0)) {
      $register_array['download_button_'.$size] = "<img src=\"".get_gallery_image("download_off.gif")."\" border=\"0\" alt=\"\" />";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<img src=\"".get_gallery_image("download_zip_off.gif")."\" border=\"0\" alt=\"\" />" : "";
    }
    else {
      $register_array['download_button_'.$size] = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size2=".$size)."\"".$target."><img src=\"".get_gallery_image("download.gif")."\" border=\"0\" alt=\"\" /></a>";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=zip&amp;".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size2=".$size."&amp;size=".$size)."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>" : "";
    }
  }
  $site_template->register_vars($register_array);


The difference lies in that I don't want to send the size value, only the size2 value because size gives the "_big" extension and size2 the name of the folder... I guess it could be changed more, to take away that function all together, but this was an easy change...

so the thing I removed was
Code: [Select]
."&amp;size=".$size from 2 places...

Of course you might want to incorporate Fox Mulder's change to have seperate buttons made for each SIZE or in this case foldername... then the code would look like this... (remember to make buttons named "download_(foldername).gif" and "download_zip_(foldername).gif" Same thing for the ones with "_off". In my case I made an image called "download_big.gif" and one called "download_off_big.jpg)

Code: [Select]
 $additional_download_sizes = array(800, 1024, 1280, 1600, big);

  $register_array = array();
  foreach ($additional_download_sizes as $size) {
    ereg("(.+)\.(.+)", basename($image_row['image_media_file']), $regs);
    $file = ((is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/" : MEDIA_PATH."/".$image_row['cat_id']."/").$size."/".$regs[1].".".$regs[2];
    if (!$allow_download || !get_file_path($file, "media", $image_row['cat_id'], 0, 0)) {
      $register_array['download_button_'.$size] = "<img src=\"".get_gallery_image("download_off_$size.gif")."\" border=\"0\" alt=\"\" />";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<img src=\"".get_gallery_image("download_zip_off_$size.gif")."\" border=\"0\" alt=\"\" />" : "";
    }
    else {
      $register_array['download_button_'.$size] = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size2=".$size)."\"".$target."><img src=\"".get_gallery_image("download_$size.gif")."\" border=\"0\" alt=\"\" /></a>";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=zip&amp;".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size2=".$size."&amp;size=".$size)."\"><img src=\"".get_gallery_image("download_zip_$size.gif")."\" border=\"0\" alt=\"\" /></a>" : "";
    }
  }
  $site_template->register_vars($register_array);



Now, I can have a folder named big that works with other mod, I also now have the option of having a download button for getting the biggest file placed in the big folder...
I also have the option of having different folders with different sizes, and downloadbuttons for them...

All in all! I am very pleased!

We are here to share... right??

Thanx!
Title: Different download options / Verschiedene Download Möglichke
Post by: mparker on March 12, 2003, 01:47:14 AM
Hello,

I have been trying to use this mod to make it so that if someone clicks on the download link it will download a PDF file. The PDF file will reside in a folder named PDF and have the same name as the image except .jpg will be replaced with .pdf. Is this something that is possible?

Could someone point me in the right direction on how to get this done?

I am sorry if this is a stupid question but my php skills are lacking.

I have also posted this in a new thread.

Thanks for your help.

Matt
Title: Different download options / Verschiedene Download Möglichke
Post by: Chris on March 12, 2003, 03:32:40 AM
Why not just set the download URL to the location of your pdf file?  No mod is needed.

Quote
Download URL
If you fill out this field, the download button will point to the URL you entered, otherwise it will point directly to the image file.

taken from the upload image page.
Title: Different download options / Verschiedene Download Möglichke
Post by: mparker on March 12, 2003, 03:47:49 AM
Quote from: Chris
Why not just set the download URL to the location of your pdf file?  No mod is needed.

Quote
Download URL
If you fill out this field, the download button will point to the URL you entered, otherwise it will point directly to the image file.
taken from the upload image page.

Chris,

Thanks for your help. I knew I could this for each individual image but I want to make this change system wide. It would be a whole lot easier to mod it somehow than to have to do this to hundreds of images. I have tried everything I can think of to try and get it to work. Thanks in advance if anyone can help with this.

Matt
Title: Different download options / Verschiedene Download Möglichke
Post by: Jan on March 12, 2003, 11:18:06 AM
Try this in download.php (not tested):

Add
Code: [Select]
ereg("(.+)\.(.+)", $file['file_path'], $regs);
$file['file_path'] = $regs[1].'.pdf';

below
Code: [Select]
if (!empty($file['file_path'])) {
Jan
Title: Different download options / Verschiedene Download Möglichke
Post by: mparker on March 12, 2003, 03:56:53 PM
Quote from: Jan
Try this in download.php (not tested):

Add
Code: [Select]
ereg("(.+)\.(.+)", $file['file_path'], $regs);
$file['file_path'] = $regs[1].'.pdf';

below
Code: [Select]
if (!empty($file['file_path'])) {
Jan


Hell Jan,

Thanks a bunch for your help. This doesn't seem to work. If I am reading the code correctly and it is very possible that I am not I need to have the pdf file in the media folder in place of the jpg file, is this correct? If I do this something downloads but it is just an error code file named with the file name I attempted to download. What I would like to do is have a thumbnail on the thumbnail page and then on the detail page have a larger preview appear but the download button will download a pdf file of the image. Maybe this isn't possible and I need to do it by hand.

Thanks again for your help.

Matt
Title: Different download options / Verschiedene Download Möglichke
Post by: Jan on March 12, 2003, 04:48:04 PM
Ok, sorry. I did a little mistake. Place
Code: [Select]
ereg("(.+)\.(.+)", $file['file_path'], $regs);
$file['file_path'] = $regs[1].'.pdf';
   
ereg("(.+)\.(.+)", $file['file_name'], $regs);
$file['file_name'] = $regs[1].'.pdf';

below
Code: [Select]
if (!empty($file['file_path'])) {
You can now have thumbnail and image files. Pressing the download button offers you a pdf file for download which has the same name as the image file and is located in the same folder:

/data/media/1/test.jpg
/data/media/1/test.pdf

/data/thumbnails/1/test.jpg

Jan
Title: Different download options / Verschiedene Download Möglichke
Post by: mparker on March 12, 2003, 07:48:14 PM
Thanks Jan, this works great.
Title: Different download options / Verschiedene Download Möglichke
Post by: Kollega on May 06, 2003, 12:16:37 PM
o.k. - new way!

some different download options are too much work so i want to go a little bit different way.

in want to create a folder in /4images/data/download and let a cronjob make a mirror for new files and directories (first run all new!) - the download folder holds the maximum Quality of my pic´s.

the images in the "normal" /media directory will be resized with "Auto Image Resizer" to a low resolution!

now my question (because my php knowledge is very poor and I don´t want to make great mistakes):

is there a easy way to change the download path for all images to /4images/download/...

thx
Kollega
Title: Different download options / Verschiedene Download Möglichke
Post by: Jan on May 06, 2003, 05:44:57 PM
You have to change just a few lines in download.php. Look for $file['file_path'] an $file_path.

Jan
Title: Different download options / Verschiedene Download Möglichke
Post by: Kollega on May 08, 2003, 02:14:41 PM
little bit confused now: reading code for about 2 hours - u said I should search for $file_path and so on

Code: [Select]
$file_path = MEDIA_PATH."/".$image_row['cat_id']."/".$image_row['image_media_file'];

now I´m confused with the MEDIA_PATH? is media_path a global declaration? should I change this one? - or should I creat a DOWNLOAD_PATH?
Title: Different download options / Verschiedene Download Möglichke
Post by: Kollega on May 08, 2003, 02:52:55 PM
I think I did it:

look for
Code: [Select]
$file_path = MEDIA_PATH."/".$image_row['cat_id']."/".$image_row['image_media_file'];

and replace it with
Code: [Select]
$file_path = ROOT_PATH."/data/download/".$image_row['cat_id']."/".$image_row['image_media_file'];

only 2 changes! - seems it works!  :D

now I only have to change the image_file_size printout in the details? - any tips where to do so?
b.t.w. if anyone is wondering: the user uploads will go into the normal media directory - after midnight a rsync cronjob will creata a exclude list from the "download" directory and copy the new files into the download directory - after that image magick starts a cronjob resizing the media pictures!
Title: some optitions...
Post by: Sheep707 on May 08, 2003, 03:33:43 PM
I's it possible edit the code (I'm just beginner in PHP) for this opitions:and "normal" media floder -> show the normal picure and download the the one from the downlad folder
If I upload a file only to the downlad folder, resize with a script the file and save it to the normal folder! So there are two different pictures![/list:u]

Or is it too many of work?
Title: Re: some optitions...
Post by: Kollega on May 08, 2003, 05:10:12 PM
Quote from: Sheep707
(I'm just beginner in PHP)


me too  :)

think its possible with a if - elseif circle but i ´ve no need! perhaps i´ll try it if i have more time! *sorry*

I´ve made a second installation and work with "try & error"  :D

btw.

the image size in the detail page i found in /includes/functions.php beginning in line 238
search for
Code: [Select]
$file_size = "n/a";
  if (!is_remote($image_row['image_media_file'])) {
    if ($file_size = @filesize(MEDIA_PATH."/".$image_row['cat_id']."/".$image_row['image_media_file'])) {
      $file_size = format_file_size($file_size);
    }
  }


replace with
Code: [Select]
$file_size = "n/a";
  if (!is_remote($image_row['image_media_file'])) {
    if ($file_size = @filesize(ROOT_PATH."/data/download/".$image_row['cat_id']."/".$image_row['image_media_file'])) {
      $file_size = format_file_size($file_size);
    }
  }


works fine until now - "Auto image resize" isn´t hurt so far I´ve testet it - seems it works fine in the standard /media directory!

so long
Kollega
Title: Different download options / Verschiedene Download Möglichke
Post by: mdevane on May 17, 2003, 09:45:08 PM
Hi Jan - Tested your mod and it works very well.  Unfortunately, it requires uploading the high/alt res photos into the same directory as the base image.  This could cause all image resolutions to be "checked" into the database, if the user were not careful.

Could this hack be modified to locate the alternative resolution images into a subdirectory (e.g - yoursite/4images/data/media/#/72dpi or  yoursite/4images/data/media/#/150dpi)?  This would minimize chance of indexing the alternate resolution images using the batch upload capability.
Title: Different download options / Verschiedene Download Möglichke
Post by: Jan on May 20, 2003, 09:50:37 AM
Try to change this line:
Code: [Select]
$file = ((is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/" : MEDIA_PATH."/".$image_row['cat_id']."/").$regs[1]."_".$size.".".$regs[2];
to
Code: [Select]
$file = ((is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/" : MEDIA_PATH."/".$image_row['cat_id']."/").'highres/'.$regs[1]."_".$size.".".$regs[2];
Now you can create a subfolders called "highres" and store the additional images in it.

Jan
Title: Different download options / Verschiedene Download Möglichke
Post by: mantra on May 20, 2003, 11:54:49 AM
Quote
Ok, sorry. I did a little mistake. Place
Code:


ereg("(.+)\.(.+)", $file['file_path'], $regs);  
$file['file_path'] = $regs[1].'.pdf';
     
ereg("(.+)\.(.+)", $file['file_name'], $regs);  
$file['file_name'] = $regs[1].'.pdf';


 

below
Code:


if (!empty($file['file_path'])) {


 

You can now have thumbnail and image files. Pressing the download button offers you a pdf file for download which has the same name as the image file and is located in the same folder:

/data/media/1/test.jpg
/data/media/1/test.pdf

/data/thumbnails/1/test.jpg



I use this mood for RAR file is works but I got problem in another category that dont have rar file in it.
now  all download button in every detail page
will save as RAR file. not go back to the image [ JPG ] file.


My idea is, if in that folder don't have RAR file then  the dowload button back to normal again  [ just to download the images ]

any idea Jan :?:
Title: Different download options / Verschiedene Download Möglichke
Post by: Jan on May 20, 2003, 12:01:56 PM
Try this:
Code: [Select]
ereg("(.+)\.(.+)", $file['file_path'], $regs);
$file_path = $regs[1].'.rar;

if (file_exists($file_path)) {
    $file['file_path'] = $file_path;

    ereg("(.+)\.(.+)", $file['file_name'], $regs);
    $file['file_name'] = $regs[1].'.rar;
}
Title: doesn't work
Post by: mantra on May 21, 2003, 01:53:23 AM
It seem this change doesn't work Jan, I got this error when I click download button

Parse error: parse error, unexpected T_STRING in c:\myserver\scripts\gallery\download.php on line 211

Code: [Select]

if ($user_info['user_level'] != ADMIN) {
    $sql = "UPDATE ".IMAGES_TABLE."
            SET image_downloads = image_downloads + 1
            WHERE image_id = $image_id";
    $site_db->query($sql);
  }

  if (!empty($file['file_path'])) {
  ereg("(.+)\.(.+)", $file['file_path'], $regs);  
  $file_path = $regs[1].'.rar;

 if (file_exists($file_path)) {
    $file['file_path'] = $file_path;

    ereg("(.+)\.(.+)", $file['file_name'], $regs);
    $file['file_name'] = $regs[1].'.rar;  
}


      @set_time_limit(120);


Help Jan :?
Title: Different download options / Verschiedene Download Möglichke
Post by: V@no on May 21, 2003, 02:12:50 AM
I think there is little misstake, missing single quotes in two lines:
Quote
ereg("(.+)\.(.+)", $file['file_path'], $regs);
$file_path = $regs[1].'.rar';

if (file_exists($file_path)) {
    $file['file_path'] = $file_path;

    ereg("(.+)\.(.+)", $file['file_name'], $regs);
    $file['file_name'] = $regs[1].'.rar';
}
Title: Now all works
Post by: mantra on May 21, 2003, 07:07:54 AM
Now all works greats....

Thanks V@NO  :D  :D  :D
Title: Different download options / Verschiedene Download Möglichke
Post by: Jan on May 21, 2003, 10:03:25 AM
Whoops, thanks V@no!

Jan
Title: U2 Jan
Post by: mantra on May 21, 2003, 11:03:02 AM
Thanks U2 Jan.

 How to make the file size info in detail page, take from the RAR file [ not from the image ].
 :D  :D  :D
Title: Different download options / Verschiedene Download Möglichke
Post by: Jan on May 21, 2003, 11:15:30 AM
Add:
Code: [Select]
 $register_array['download_size_'.$size] = format_file_size(filesize($file));
before
Code: [Select]
 }
$site_template->register_vars($register_array);

and use {download_size_72}, {download_size_150} etc. in the template.
Title: No I mean the info size will for rar extention ?
Post by: mantra on May 21, 2003, 12:07:01 PM
No I mean the info size will for RAR  extention ? :wink:
Title: Different download options / Verschiedene Download Möglichke
Post by: Jan on May 21, 2003, 12:31:52 PM
Yes, it is. Whats the problem?  :?

Jan
Title: Ops
Post by: mantra on May 21, 2003, 12:58:14 PM
Ops sorry.

I'm confused where do I put this hack [ in detail.php ]
I search for this code in detail, but I couldn't found it.

Code: [Select]
}  
$site_template->register_vars($register_array);
Title: Different download options / Verschiedene Download Möglichke
Post by: Jan on May 21, 2003, 01:05:42 PM
Ok, sorry. See: http://www.4homepages.de/forum/viewtopic.php?p=7846#7846

Jan
Title: Different download options / Verschiedene Download Möglichke
Post by: mantra on May 22, 2003, 01:32:14 PM
I still confused Jan ,My idea is just for info file RAR only in spesific category ,
because I don't use this mood for deferent image like you said .
I just use litle hack from this code.

.
Code: [Select]

ereg("(.+)\.(.+)", $file['file_path'], $regs);
$file_path = $regs[1].'.rar';

if (file_exists($file_path)) {
$file['file_path'] = $file_path;

ereg("(.+)\.(.+)", $file['file_name'], $regs);
$file['file_name'] = $regs[1].'.rar';
}



I use this as a download for my template

----------------------------------------------------
Please take a look at my web

user: dream
password : kacanggoreng

www.mantradigital.com/gallery/

visit in DREAM SKINS category after get in detail page,

on info file by default it take from the image JPG file, my wish is the info size file
get from the RAR .


Thanks for taking your time Jan
Title: Different download options / Verschiedene Download Möglichke
Post by: Jan on May 22, 2003, 02:56:16 PM
Ok, i hope this is what you want:

Open functions.php and add

Code: [Select]
ereg("(.+)\.(.+)", $image_row['image_media_file'], $regs);  
$rar_path = MEDIA_PATH."/".$image_row['cat_id']."/".$regs[1].'.rar';  

$rar_size = 0;
if (file_exists($rar_path)) {  
    $rar_size = format_file_size(filesize($rar_path));
}

after
Code: [Select]
elseif ($detailed_view) {
  $file_size = get_remote_file_size($image_row['image_media_file']);
}

and add
Code: [Select]
"rar_file_size" => $rar_size,
after
Code: [Select]
"image_file_size" => $file_size,
Then use {rar_file_size} in the templates.

Jan
Title: Yeap
Post by: mantra on May 22, 2003, 03:39:57 PM
Yesss you make my day Jan :D  :D  :D

Thanks
Title: Re: Different download options / Verschiedene Download Möglichke
Post by: Gulper on June 24, 2005, 02:57:47 AM
Is there a way to integrate this mod somehow into the ACP?
It would be great, if I can add more than currently one download... If for example I have three downloads for one image, I enter three different download urls in the ACP for this one image or movie.... then in the details of this picture or movie, the three downloads are visible... if I only enter two downloads, only these are visible... etc...
Would be also great, if I could assign a seperate download button to each download... That would be awsome! :)
Can someone adjust this mod?
Title: Re: Different download options / Verschiedene Download Möglichke
Post by: headmax on September 01, 2005, 12:27:07 PM
great mod, it works fine.
but is it possible to show the file-size and the resolution of the big picture?

thanks headmax
Title: Re: Different download options / Verschiedene Download Möglichke
Post by: jkn on September 02, 2005, 02:12:52 PM
hey guy's,

it's possible to change this mod so different users have different download options??? also for example: 

1. guests can download files from cat_id/ and cat_id/big folder and
2. only registered members can download files vom cat_id/highres folder !????

thx for your help!!
jkn 
Title: Re: Different download options / Verschiedene Download Möglichke
Post by: khan on November 06, 2005, 07:01:08 PM
Hi guys
i am using 4images for music site and there i have each song in 3 formats ".rm" ".wma" and ".mp3". when a user click on thumbnail and he enter to details page the song is start playing in .wma format and the default buttons for download is linked to this wma file but now what i want that to put 2 more buttons on details page and link it to ".rm" and the ".mp3" file.

any help will be apriciated :)

Title: Re: Different download options / Verschiedene Download Möglichke
Post by: newb on December 02, 2005, 10:00:42 PM
hey guy's,

it's possible to change this mod so different users have different download options??? also for example: 

1. guests can download files from cat_id/ and cat_id/big folder and
2. only registered members can download files vom cat_id/highres folder !????

thx for your help!!
jkn 

I was wondering the same thing. That would fit perfectly.
Title: Re: Different download options / Verschiedene Download Möglichke
Post by: Eagle Eye on February 09, 2006, 01:55:42 PM
I think I did it:

look for
Code: [Select]
$file_path = MEDIA_PATH."/".$image_row['cat_id']."/".$image_row['image_media_file'];
and replace it with
Code: [Select]
$file_path = ROOT_PATH."/data/download/".$image_row['cat_id']."/".$image_row['image_media_file'];
only 2 changes! - seems it works!  :D

I want to resize all images and keep the original in a folder called "download" i tried the above modification, but it still seems to be taking the file from the original cat if folder (the file that I resized and not the saved original in download folder) what could be wrong?

path: resized image: .../data/#/  and orginal: .../data/#/download/

Thanks in advance
Title: Re: Different download options / Verschiedene Download Möglichke
Post by: obmob01 on February 09, 2006, 08:45:00 PM
Ok, i hope this is what you want:

Open functions.php and add

Code: [Select]
ereg("(.+)\.(.+)", $image_row['image_media_file'], $regs);  
$rar_path = MEDIA_PATH."/".$image_row['cat_id']."/".$regs[1].'.rar';  

$rar_size = 0;
if (file_exists($rar_path)) {  
    $rar_size = format_file_size(filesize($rar_path));
}
after
Code: [Select]
elseif ($detailed_view) {
  $file_size = get_remote_file_size($image_row['image_media_file']);
}
and add
Code: [Select]
"rar_file_size" => $rar_size,after
Code: [Select]
"image_file_size" => $file_size,Then use {rar_file_size} in the templates.

Jan
This was incredibly useful, thanks, i was having that problem with ZIP files :)
Title: Re: Different download options / Verschiedene Download Möglichke
Post by: fotograf74 on April 26, 2006, 08:22:49 PM
I read the whole thread. Is there any example in the web to see this mod in action?

Can I do this with the mod?
- upload a high-res picture
- automatic resized in 4 sizes, which are automatic saved in different folders
- can put each in the lightbox
- download the lightbox (cart)
Title: Re: Different download options / Verschiedene Download Möglichke
Post by: Eagle Eye on May 08, 2006, 12:35:23 PM
Try to change this line:
Code: [Select]
$file = ((is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/" : MEDIA_PATH."/".$image_row['cat_id']."/").$regs[1]."_".$size.".".$regs[2]; to
Code: [Select]
$file = ((is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/" : MEDIA_PATH."/".$image_row['cat_id']."/").'highres/'.$regs[1]."_".$size.".".$regs[2]; Now you can create a subfolders called "highres" and store the additional images in it.

Jan

Thanks for this MOD
I am using jan's original mod http://www.4homepages.de/forum/index.php?topic=1861.msg7846#msg7846 and with a little modification with http://www.4homepages.de/forum/index.php?topic=1861.msg9178#msg9178 and my own for the active buttons (cause it was showing the same donwload.gif) i got the buttons working...

but when i press download... it is downloading an empty file with 789 bytes.. and correct file name   8O

what must have gone wrong?
Title: Re: Different download options / Verschiedene Download Möglichke
Post by: IWS_steffen on May 09, 2006, 10:56:55 PM
great mod, it works fine.

thanks steffen
Title: Re: Different download options / Verschiedene Download Möglichke
Post by: GhostPool on July 30, 2006, 01:00:10 AM
Is it possible someone could modify this code slightly so that I can have some of the download options available to everyone, whilst other's only available to registered users.
Title: Re: Different download options / Verschiedene Download Möglichke
Post by: sajwal on July 30, 2006, 03:08:03 AM
Hi Jan,
         You will have to really help me with this! :D (you have already done something like this now!)

I want to provide my registered users with the source file of an image
viz : 1. either *.cdr   2. *.psd   or 3. *.ai  but the guest with only the *.jpg of it
Now, I want to show three download buttons to registered members (for *.cdr, *.psd and *.ai),
if i upload only one of the format source file - the rest two should get blurred,
if i upload two the third should get blurred and
 if all three formats , all should be active

Thanks in advance Jan, please take this pain ... i dont know php and i am helpless
Title: Re: Different download options / Verschiedene Download Möglichke
Post by: GhostPool on August 02, 2006, 01:41:14 PM
Is it possible someone could modify this code slightly so that I can have one of the download options available to everyone, whilst the others only available to registered users.
Any help here for my above query. I'm hoping it's something easy to change, or maybe you could just allow the default {download_button} to be available to everyone regardless of the option selected in the Control Panel.
Title: Re: Different download options / Verschiedene Download Möglichke
Post by: GhostPool on August 29, 2006, 03:11:56 PM
Again I ask is there a way to adapt this Mod so that some of the download options can be available to guests, whilst other's are available to members only. Hope someone can help. Thanks.
Title: Re: Different download options / Verschiedene Download Möglichke
Post by: Eagle1 on October 15, 2006, 11:22:57 AM

I read the whole thread. Is there any example in the web to see this mod in action?

Can I do this with the mod?
- upload a high-res picture
- automatic resized in 4 sizes, which are automatic saved in different folders
- can put each in the lightbox
- download the lightbox (cart)

I have same question. Is this possible?

I am surprised, that this feature is not in the CORE  :( Every Photographer which will offer Images over the web needs this function. Preview images, and download the full Print version and Full Size of an Image. So I hope this feature is in Core as Donwload Option in the Future, also a simple Workflow to Upload ONE Image and generate all other Thumbs from this one. No Upload more Images....

Thanks Roland
Title: Re: Different download options / Verschiedene Download Möglichke
Post by: flokoc on October 22, 2006, 05:42:16 PM
I think I did it:

look for
Code: [Select]
$file_path = MEDIA_PATH."/".$image_row['cat_id']."/".$image_row['image_media_file'];
and replace it with
Code: [Select]
$file_path = ROOT_PATH."/data/download/".$image_row['cat_id']."/".$image_row['image_media_file'];
only 2 changes! - seems it works!  :D

I want to resize all images and keep the original in a folder called "download" i tried the above modification, but it still seems to be taking the file from the original cat if folder (the file that I resized and not the saved original in download folder) what could be wrong?

path: resized image: .../data/#/  and orginal: .../data/#/download/

Thanks in advance



I have the same problem. Anyone knows how to solve the problem ?
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: Lukazs on November 01, 2006, 02:11:11 PM
I got no error, but my additional download buttons is blured (like i would not have permissions to download image, but i am sure that download option in CP is set to "ALL" and normal download button is working fine.) What could be that? maybe my 4images version is bad? My version 1.7.3.

Thank you for help and your time.
Title: Re: Different download options / Verschiedene Download Möglichke
Post by: petya on November 09, 2007, 11:20:05 PM

I read the whole thread. Is there any example in the web to see this mod in action?

Can I do this with the mod?
- upload a high-res picture
- automatic resized in 4 sizes, which are automatic saved in different folders
- can put each in the lightbox
- download the lightbox (cart)

I have same question. Is this possible?

I am surprised, that this feature is not in the CORE  :( Every Photographer which will offer Images over the web needs this function. Preview images, and download the full Print version and Full Size of an Image. So I hope this feature is in Core as Donwload Option in the Future, also a simple Workflow to Upload ONE Image and generate all other Thumbs from this one. No Upload more Images....

Thanks Roland

He is got it wright. That how the progam should work.
Have anybody find the answer to Roland's question?
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: Intellutions on December 02, 2007, 03:36:30 PM

Kudos: This is a great mod, thank you.  I was able to change it a bit to support multiple file types instead of different resolutions, and it's working very well for that.

Problem: It seems the code placed into functions.php (after the "$allow_download = 1;" line) runs not only for the detail image, but also for the Random Image that appears to the left of the page.  In fact, it looks to run twice for that image, then once for the detail image.

This might not sound like an issue, but it is when I don't have all the same file types for all the images in the gallery. :(

What happens, is the {download_button} arrays are generated but if the random image has a file type that the detail image doesn't, the {download_button} for that file type is actually for the random image when it appears on the page.  (If the file type existed for the detail image that array would have been overwritten.)

Question:  Is there a way to make sure that the {download_button} arrays are only generated for the detail image, and not the random image that's also on the page?

I found I have access to the image_id field when building the arrays, so I was tempted to use that in the {download_button} array name, but I don't know if I can build those array names on the fly in details.html when the page loads.

Any ideas?

Thank You,
Rich
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: jojomart on December 12, 2007, 10:39:11 PM
OK, guys I need your help  :(

I've created a new directory under one of my categories and called it "800" because the images inside of the folder are 800 x 600. I've replaced all the main images for the category into 1024 x 768, so I don't need an additional button for those, and they are showing up fine on the details page.

Here is the code I changed for the mod:

Code: [Select]
$additional_download_sizes = array(800);

  $register_array = array();
  foreach ($additional_download_sizes as $size) {
    ereg("(.+)\.(.+)", basename($image_row['image_media_file']), $regs);
    $file = ((is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/" : MEDIA_PATH."/".$image_row['cat_id']."/").$size."/".$regs[1].".".$regs[2];
    if (!$allow_download || !get_file_path($file, "media", $image_row['cat_id'], 0, 0)) {
      $register_array['download_button_'.$size] = "<img src=\"".get_gallery_image("download_800_off.gif")."\" border=\"0\" alt=\"\" />";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<img src=\"".get_gallery_image("download_800_zip_off.gif")."\" border=\"0\" alt=\"\" />" : "";
    }
    else {
      $register_array['download_button_'.$size] = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size2=".$size."&amp;size=".$size)."\"".$target."><img src=\"".get_gallery_image("download_800.gif")."\" border=\"0\" alt=\"\" /></a>";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=zip&amp;".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size2=".$size."&amp;size=".$size)."\"><img src=\"".get_gallery_image("download_800_zip.gif")."\" border=\"0\" alt=\"\" /></a>" : "";
    }
  }
  $site_template->register_vars($register_array);

It's probably not right LOL

Here's what I put in my details.html file:

Code: [Select]
&nbsp;&nbsp;&nbsp;&nbsp;{download_button_800}&nbsp;&nbsp;{download_zip_button_800}
[EDIT]
The 800 buttons are showing up on the details page, but they're grayed out, so I can't use them, even when I've logged in.

What do I have to change in the script so that the code will know to look for the 800 sized images in that directory. Do these new 800 images have to be inserted into the database too? And if so, how do I do that?

Please help quick  :oops:

Joanne


EDIT:

WOOHOO I got it working, only thing now is I have to start from scratch - delete what's in my database already and start over "groan"
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: scaners on December 16, 2007, 08:52:19 AM
Whether and it is possible to make so that it was possible to appoint buttons not to all categories, and for what that of the certain categories?
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: jojomart on December 29, 2007, 05:46:04 AM
Ok, everyone, I almost have it working where guests can download one size 800x600, but only registered users can download 1024x768 images. Only problem I'm having is that the registered users buttons for the 1024 are showing greyed out even when they're logged in. I added a new column in the categories table - auth_download_1024, and added a line in admin's edit categories section to set the regular downloads to "All" for guests and registered users, and the 1024x768 downloads to "Registered Users" only, and I checked the database and it is applying the permissions correctly.

Here is my code from includes/functions.php

Code: [Select]
  if (!check_permission("auth_download", $image_row['cat_id'])) {
    $download_button = "<img src=\"".get_gallery_image("download_off.gif")."\" border=\"0\" alt=\"\" />";
    $download_zip_button = (function_exists("gzcompress") && function_exists("crc32")) ? "<img src=\"".get_gallery_image("download_zip_off.gif")."\" border=\"0\" alt=\"\" />" : "";
    $allow_download = 0;
    clear_download_token($image_row['image_id']);
  }
  else {
    $target = (!empty($image_row['image_download_url']) && !is_remote_file($image_row['image_download_url']) && !is_local_file($image_row['image_download_url'])) ? "target=\"_blank\"" : "";
    $download_button = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id'])."\"".$target."><img src=\"".get_gallery_image("download.gif")."\" border=\"0\" alt=\"\" /></a>";
    $download_zip_button = ($target == "" && function_exists("gzcompress") && function_exists("crc32")) ? "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=zip&amp;".URL_IMAGE_ID."=".$image_row['image_id'])."\"".$target."><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>" : "";
    $allow_download = 1;

 $additional_download_sizes = array(1024);

  $register_array = array();
  foreach ($additional_download_sizes as $size) {
    ereg("(.+)\.(.+)", basename($image_row['image_media_file']), $regs);
    $file = ((is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/" : MEDIA_PATH."/".$image_row['cat_id']."/").$regs[1]."_".$size.".".$regs[2];
  if (!check_permission("auth_download_1024", $image_row['cat_id'])) {
      $register_array['download_button_'.$size] = "<img src=\"".get_gallery_image("download_off_1024.gif")."\" border=\"0\" alt=\"\" />";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<img src=\"".get_gallery_image("download_zip_off_1024.gif")."\" border=\"0\" alt=\"\" />" : "";
    $allow_download = 0;
    clear_download_token($image_row['image_id']);
    }
    else {
      $register_array['download_button_'.$size] = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size=".$size)."\"".$target."><img src=\"".get_gallery_image("download_1024.gif")."\" border=\"0\" alt=\"\" /></a>";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=zip&amp;".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size=".$size)."\"><img src=\"".get_gallery_image("download_zip_1024.gif")."\" border=\"0\" alt=\"\" /></a>" : "";
    $allow_download = 1;
    }
  }
  $site_template->register_vars($register_array);
 

I'd really appreciate it if someone could tell me where I'm going wrong with the code.

Hey another weird thing happened since doing this - I have installed the code to place a thumbnail next to the category title on the main page, but when I click to make a change in the "Edit Categories" section, the image number for the category thumb disappears, and I have to reinsert it each time I modify the section.  Any ideas why??

Thanks,

Joanne
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: jojomart on December 30, 2007, 05:45:49 PM
Hey Everyone!

GOT IT WORKING!!!

Here's Jan's original code from page 2:

Code: [Select]
  $additional_download_sizes = array(72, 120, 300);

  $register_array = array();
  foreach ($additional_download_sizes as $size) {
    ereg("(.+)\.(.+)", basename($image_row['image_media_file']), $regs);
    $file = ((is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/" : MEDIA_PATH."/".$image_row['cat_id']."/").$size."/".$regs[1].".".$regs[2];
    if (!$allow_download || !get_file_path($file, "media", $image_row['cat_id'], 0, 0)) {
      $register_array['download_button_'.$size] = "<img src=\"".get_gallery_image("download_off.gif")."\" border=\"0\" alt=\"\" />";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<img src=\"".get_gallery_image("download_zip_off.gif")."\" border=\"0\" alt=\"\" />" : "";
    }
    else {
      $register_array['download_button_'.$size] = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size2=".$size."&amp;size=".$size)."\"".$target."><img src=\"".get_gallery_image("download.gif")."\" border=\"0\" alt=\"\" /></a>";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=zip&amp;".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size2=".$size."&amp;size=".$size)."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>" : "";
    }
  }
  $site_template->register_vars($register_array);

And here's what I changed it to:

Code: [Select]
$additional_download_sizes = array(1024);
$register_array = array();
foreach ($additional_download_sizes as $size) {
    ereg("(.+)\.(.+)", basename($image_row['image_media_file']), $regs);
    $file = ((is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/" : MEDIA_PATH."/".$image_row['cat_id']."/").$size."/".$regs[1].".".$regs[2];
  if (!check_permission("auth_download_$size", $image_row['cat_id'])) {

       $register_array['download_button_'.$size] = "<img src=\"".get_gallery_image("download_off_$size.gif")."\" border=\"0\" alt=\"\" />";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<img src=\"".get_gallery_image("download_zip_off_$size.gif")."\" border=\"0\" alt=\"\" />" : "";

    }
    else {
      $register_array['download_button_'.$size] = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size=".$size)."\"".$target."><img src=\"".get_gallery_image("download_$size.gif")."\" border=\"0\" alt=\"\" /></a>";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=zip&amp;".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size=".$size)."\"><img src=\"".get_gallery_image("download_zip_$size.gif")."\" border=\"0\" alt=\"\" /></a>" : "";

}

  }
  $site_template->register_vars($register_array);
 

So this:

Code: [Select]
    if (!$allow_download || !get_file_path($file, "media", $image_row['cat_id'], 0, 0)) {
was changed to this:

Code: [Select]
  if (!check_permission("auth_download_$size", $image_row['cat_id'])) {
So now my non-registered visitors will only be able to download 800 x 600 wallpapers, but my registered visitors will be able to download both 800 x 600 and 1024 x 768 wallpapers. And for the non-registered visitors it shows the 1024 x 768 buttons, but they are greyed out, and there are no links showing even in page source, so they can't get the link to the bigger size!

Joanne
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: thunderstrike on December 30, 2007, 06:44:16 PM
Very good but please change:

Code: [Select]
ereg("(.+)\.(.+)", basename($image_row['image_media_file']), $regs);

for:

Code: [Select]
ereg("(.+)\.(.+)", get_basefile(stripslashes(trim($image_row['image_media_file']))), $regs);

And correct for check_permission function . Is right one for permission. ;)
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: jojomart on December 30, 2007, 07:42:40 PM
Thanks!
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: jojomart on January 06, 2008, 04:56:22 PM
Hi everyone,

I am using the different downloads options mod, as well as the batch copy and move mod, and I'd like to allow the script to look in a different directory for the new images when I'm using the Check New Images" feature. Right now it only looks in the base category id. What I want to do is allow it to look in a different subfolder - ex: catid 19/1024/ for newly uploaded images, as well as looking in the base folder. The reason I need this is that I want to upload some 1600x1200 images into the already created 1024 subfolder, then convert them to 1024x768 and save the original 1600x1200 file into a new subfolder called 1600.

I hope I explained it ok - can someone help me with this?

Thanks!

Joanne

EDIT:  Never mind - I decided I'll stick with the two sizes for now - it's just too much trouble.
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: jojomart on January 08, 2008, 10:57:24 PM
I made a widescreen category that has jpg's in just the one size of 1440 x 900 - and I want to allow a button for only that size on the widescreen details page - is that possible? or should I just leave the regular buttons there and they can download it with the regular download button? There is only the one size in that category so they're in media/20/ with no subfolders

Thanks,

Joanne
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: jojomart on January 09, 2008, 04:13:45 PM
I was asked to move this topic here:

I can't figure out how to get the zip downloads in lightbox to download everything I have in there. It only wants to download one at a time. Isn't it supposed to download whatever you have listed there? I do have this mod installed, and maybe this is the problem?

I'm using 1.74 script.

thanks,

Joanne
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: thunderstrike on January 09, 2008, 05:13:31 PM
I was asked to move this topic here:

I can't figure out how to get the zip downloads in lightbox to download everything I have in there. It only wants to download one at a time. Isn't it supposed to download whatever you have listed there? I do have this mod installed, and maybe this is the problem?

This is right. I check Jan code and ZIP is no work from lightbox. I no test this but I like this so here:

In includes/functions.php file,

find:

Code: [Select]
 $register_array = array();
  foreach ($additional_download_sizes as $size) {
    ereg("(.+)\.(.+)", basename($image_row['image_media_file']), $regs);
    $file = ((is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/" : MEDIA_PATH."/".$image_row['cat_id']."/").$regs[1]."_".$size.".".$regs[2];
    if (!$allow_download || !get_file_path($file, "media", $image_row['cat_id'], 0, 0)) {
      $register_array['download_button_'.$size] = "<img src=\"".get_gallery_image("download_off.gif")."\" border=\"0\" alt=\"\" />";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<img src=\"".get_gallery_image("download_zip_off.gif")."\" border=\"0\" alt=\"\" />" : "";
    }
    else {
      $register_array['download_button_'.$size] = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size=".$size)."\"".$target."><img src=\"".get_gallery_image("download.gif")."\" border=\"0\" alt=\"\" /></a>";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=zip&amp;".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size=".$size)."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>" : "";
    }
  }
  $site_template->register_vars($register_array);

replace:

Code: [Select]
 $register_array = array();
  foreach ($additional_download_sizes as $size) {
    preg_match("/(.+)\.(.+)/", get_basefile(stripslashes(trim($image_row['image_media_file']))), $regs);
    $file = ((is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/" : MEDIA_PATH."/".$image_row['cat_id']."/").$regs[1]."_".$size.".".$regs[2];
    if (!$allow_download || !get_file_path($file, "media", $image_row['cat_id'], 0, 0)) {
      $register_array['download_button_'.$size] = "<img src=\"".get_gallery_image("download_off_" . $size . ".gif")."\" border=\"0\" alt=\"\" />";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<img src=\"".get_gallery_image("download_zip_off_" . $size . ".gif")."\" border=\"0\" alt=\"\" />" : "";
    } elseif ($allow_download && get_file_path($file, "media", $image_row['cat_id'], 0, 0) && preg_match("/lightbox\.php/", $self_url) && sizeof($user_info['lightbox_image_ids']) > 0 && function_exists("gzcompress") && function_exists("crc32")) {
      $register_array['download_zip_button_'.$size] = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=lightbox&amp;size=" . $size)."\"".$target."><img src=\"".get_gallery_image("download_zip_" . $size . ".gif")."\" border=\"0\" alt=\"\" /></a>";
    } elseif ($allow_download && get_file_path($file, "media", $image_row['cat_id'], 0, 0) && preg_match("/lightbox\.php/", $self_url) && sizeof($user_info['lightbox_image_ids']) <= 0 || !function_exists("gzcompress") || !function_exists("crc32")) {
      $register_array['download_zip_button_'.$size] = "<img src=\"".get_gallery_image("download_zip_off_" . $size . ".gif")."\" border=\"0\" alt=\"\" />";
    }
    else {
      $register_array['download_button_'.$size] = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size=".$size)."\"".$target."><img src=\"".get_gallery_image("download_" . $size . ".gif")."\" border=\"0\" alt=\"\" /></a>";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=zip&amp;".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size=".$size)."\"><img src=\"".get_gallery_image("download_zip_" . $size . ".gif")."\" border=\"0\" alt=\"\" /></a>" : "";
    }
  }
  $site_template->register_vars($register_array);
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: jojomart on January 09, 2008, 05:55:55 PM
I changed what you said to and got the following error messages:

Warning: Invalid argument supplied for foreach() in /home/wannaber/public_html/wallpaper-downloads/includes/functions.php on line 378

Warning: Invalid argument supplied for foreach() in /home/wannaber/public_html/wallpaper-downloads/includes/functions.php on line 378

Warning: Invalid argument supplied for foreach() in /home/wannaber/public_html/wallpaper-downloads/includes/functions.php on line 378

Warning: Invalid argument supplied for foreach() in /home/wannaber/public_html/wallpaper-downloads/includes/functions.php on line 378
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: thunderstrike on January 09, 2008, 05:59:25 PM
You no follow instruction correct. I no say for change this: $additional_download_sizes = array(72, 150, 300); (is first line from jan - page 1 in topic). ;)
My instruction is start with: $register_array = array();

Please add array in first line again ...
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: jojomart on January 09, 2008, 06:09:23 PM
I did it, but it is no better - still only one download - plus now my 1024 button is not there with your code
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: thunderstrike on January 09, 2008, 06:17:28 PM
Quote
plus now my 1024 button is not there with your code

And ... you see lightbox image in page ? ... Is no empty ... ?
And not there ... what is not there ... ? Not there gone ? Not there replace ?
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: jojomart on January 09, 2008, 06:24:22 PM
Nope it's not empty - I changed it back to the old functions.php because what you gave me was also messing up the details.php pages - they couldn't download the 1024 anymore.

Here is screenshot:

(http://www.wallpaper-downloads.info/capture1.jpg)

Edit: Sorry missed second question - yeah it showed a greyed out copy of the regular download button
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: thunderstrike on January 09, 2008, 06:25:51 PM
I see screenshot of 1024 with old code but where is screenshot of 1024 with new code ?

Quote
Edit: Sorry missed second question - yeah it showed a greyed out copy of the regular download button

Ah ! ok ... what is button image name of download button use for 1024 ?
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: jojomart on January 09, 2008, 06:29:56 PM
I called it download_1024.gif and download_off_1024.gif

But I had to make a few changes even to Jan's code to make it work where unregistered can only download 800x600 and registered can download all sizes

This is the code I had to use to make both download types work:

Code: [Select]
$additional_download_sizes = array(1024);
$register_array = array();
foreach ($additional_download_sizes as $size) {
    ereg("(.+)\.(.+)", get_basefile(stripslashes(trim($image_row['image_media_file']))), $regs);
    $file = ((is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/" : MEDIA_PATH."/".$image_row['cat_id']."/").$size."/".$regs[1].".".$regs[2];
  if (!check_permission("auth_download_$size", $image_row['cat_id'])) {

       $register_array['download_button_'.$size] = "<img src=\"".get_gallery_image("download_off_$size.gif")."\" border=\"0\" alt=\"\" />";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<img src=\"".get_gallery_image("download_zip_off_$size.gif")."\" border=\"0\" alt=\"\" />" : "";

    }
    else {
      $register_array['download_button_'.$size] = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size=".$size)."\"".$target."><img src=\"".get_gallery_image("download_$size.gif")."\" border=\"0\" alt=\"\" /></a>";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=zip&amp;".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size=".$size)."\"><img src=\"".get_gallery_image("download_zip_$size.gif")."\" border=\"0\" alt=\"\" /></a>" : "";

}

  }
  $site_template->register_vars($register_array);
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: thunderstrike on January 09, 2008, 06:36:11 PM
Ok, I edit topic. Try now. ;)
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: jojomart on January 09, 2008, 07:37:18 PM
Ok, I edit topic. Try now. ;)

I don't understand - what does "I edit topic. Try now." mean?

Edit:  Ok, you changed the code - I tried it, but no luck - and it greyed out the 1024 button as well

 sorry
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: thunderstrike on January 09, 2008, 08:11:01 PM
Quote
Ok, you changed the code - I tried it, but no luck - and it greyed out the 1024 button as well

You try with name: download_1024.gif, download_off_1024.gif, download_zip_1024.gif and download_zip_off_1024.gif ?
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: jojomart on January 09, 2008, 08:40:53 PM
Quote
Ok, you changed the code - I tried it, but no luck - and it greyed out the 1024 button as well

You try with name: download_1024.gif, download_off_1024.gif, download_zip_1024.gif and download_zip_off_1024.gif ?

What I used in the lightbox.html file is

{download_zip_button}<br>{download_zip_button_1024}

I used the download_zip.gif button which enables users to download either the 800x600 images or the widescreen images
and I used the download_zip_1024.gif button for users who want to download the size of 1024 x 768

Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: thunderstrike on January 10, 2008, 02:15:13 AM
Quote
I used the download_zip.gif button which enables users to download either the 800x600 images or the widescreen images
and I used the download_zip_1024.gif button for users who want to download the size of 1024 x 768

Ok so after add last code I post, what is do if use {download_zip_button} and {download_zip_button_1024} ?
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: jojomart on January 10, 2008, 03:06:12 AM
Quote
I used the download_zip.gif button which enables users to download either the 800x600 images or the widescreen images
and I used the download_zip_1024.gif button for users who want to download the size of 1024 x 768

Ok so after add last code I post, what is do if use {download_zip_button} and {download_zip_button_1024} ?

Nothing changed - it still only downloaded the zip file with one image inside.

I'm thinking maybe I should just make a new button called Favorites and leave it at that - they won't be able to download everything at once, but at least it gives them a place to store the ones they like, and then they can choose from the lightbox page to download whichever ones they want one at a time.

EDIT: I thought I should let you know what Mods I have installed:

Different Download Options Mod (with changes for two different downloads - user and non user)
Different cat Templates Mod (use a different details.html for the 1440 x 900 images in Widescreen category)
Calendar Mod
Notify Sender on received e-Card Mod
Batch Copy Move Edit Mod
Statistics Mod
Category Image Mod
Search Engine Friendly Mod
Let Visitors Choose How To Sort Mod
Image Rate Form Mod
Random Image Mod
Check for Duplicate Images Mod

Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: thunderstrike on January 10, 2008, 03:55:45 AM
Quote
Nothing changed - it still only downloaded the zip file with one image inside.

Sorry ... I no can help more for this ... I no think is something with MOD you install for download 1 image ... if use $user_info['lightbox_image_ids'] with $size , is possible but is first time I code this ...  :|
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: jojomart on January 10, 2008, 04:55:09 AM
It's ok - thanks for taking so much time on it!

Joanne
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: jojomart on January 14, 2008, 03:56:06 PM
Hi all,

I've had to move to a new server with my hosting, and it has the latest php software. Now this mod doesn't work for me anymore  :cry:

I don't suppose there is someone here who can figure out what needs to be changed in the code to make it work, is there?

Thanks,

Joanne
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: budduke on August 29, 2008, 12:39:55 AM
I am looking at making a variation of this different download options and was wondering if anyone knew of a way to make a dropdown list next to the download/and zip button that would give you different size options?
Like a list of 72,150,300 and when you click on the download button it would download that version that was selected in the dropdown?

thanks for any input!
Title: Re: Different download options / Verschiedene Download Möglichke
Post by: Lunique on February 14, 2009, 03:32:55 PM
Thank you V@no, for that modification to the mod!!

With some modding of my own, I got it working the way I wanted it... though yours did most of the work...

The problem is if you want to use a folder that is not an integer, that is a whole number. That is because intval is used... So, I remover that from.... this... part

Code: [Select]
 if (isset($HTTP_GET_VARS['size2']) || isset($HTTP_POST_VARS['size2'])) {
    $size2 = (isset($HTTP_GET_VARS['size2'])) ? intval($HTTP_GET_VARS['size2']) : intval($HTTP_POST_VARS['size2']);
  }
  else {
    $size2 = 0;
  }

I changed it to...

Code: [Select]
if (isset($HTTP_GET_VARS['size2']) || isset($HTTP_POST_VARS['size2'])) {
    $size2 = (isset($HTTP_GET_VARS['size2'])) ? ($HTTP_GET_VARS['size2']) : ($HTTP_POST_VARS['size2']);
  }
  else {
    $size2 = 0;
  }

This way it doesn't matter if you use "1024" or "big" as the foldername....

The reason I wanted this is that I wanted to combine it with V@no's hack...
[Mod] Show original image in new window by clicking on image (http://www.4homepages.de/forum/viewtopic.php?t=3236&highlight=)!

In that mod there is a folder is named big and put into the same folder as the images(1,2,3,4...). In the big folder images are put that are (surprisingly) bigger (could of course use smaller too, but what would the point be) Then that image will pop up in a new window... Great mod, I got it working!

Now, I also wanted the option to have a download button for big and also maybe other sizes like 1024 and so on...

But in the big modification there is no extension _big placed after each imagename (and no reason to if you have it in a different foler)... so I had to remove some code from this one as well...

 
Code: [Select]
$additional_download_sizes = array(72, 120, 300);

  $register_array = array();
  foreach ($additional_download_sizes as $size) {
    ereg("(.+)\.(.+)", basename($image_row['image_media_file']), $regs);
    $file = ((is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/" : MEDIA_PATH."/".$image_row['cat_id']."/").$size."/".$regs[1].".".$regs[2];
    if (!$allow_download || !get_file_path($file, "media", $image_row['cat_id'], 0, 0)) {
      $register_array['download_button_'.$size] = "<img src=\"".get_gallery_image("download_off.gif")."\" border=\"0\" alt=\"\" />";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<img src=\"".get_gallery_image("download_zip_off.gif")."\" border=\"0\" alt=\"\" />" : "";
    }
    else {
      $register_array['download_button_'.$size] = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size2=".$size."&amp;size=".$size)."\"".$target."><img src=\"".get_gallery_image("download.gif")."\" border=\"0\" alt=\"\" /></a>";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=zip&amp;".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size2=".$size."&amp;size=".$size)."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>" : "";
    }
  }
  $site_template->register_vars($register_array);

this I changed to...

  
Code: [Select]
 $additional_download_sizes = array(800, 1024, 1280, 1600, big);

  $register_array = array();
  foreach ($additional_download_sizes as $size) {
    ereg("(.+)\.(.+)", basename($image_row['image_media_file']), $regs);
    $file = ((is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/" : MEDIA_PATH."/".$image_row['cat_id']."/").$size."/".$regs[1].".".$regs[2];
    if (!$allow_download || !get_file_path($file, "media", $image_row['cat_id'], 0, 0)) {
      $register_array['download_button_'.$size] = "<img src=\"".get_gallery_image("download_off.gif")."\" border=\"0\" alt=\"\" />";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<img src=\"".get_gallery_image("download_zip_off.gif")."\" border=\"0\" alt=\"\" />" : "";
    }
    else {
      $register_array['download_button_'.$size] = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size2=".$size)."\"".$target."><img src=\"".get_gallery_image("download.gif")."\" border=\"0\" alt=\"\" /></a>";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=zip&amp;".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size2=".$size."&amp;size=".$size)."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>" : "";
    }
  }
  $site_template->register_vars($register_array);

The difference lies in that I don't want to send the size value, only the size2 value because size gives the "_big" extension and size2 the name of the folder... I guess it could be changed more, to take away that function all together, but this was an easy change...

so the thing I removed was
Code: [Select]
."&amp;size=".$size from 2 places...

Of course you might want to incorporate Fox Mulder's change to have seperate buttons made for each SIZE or in this case foldername... then the code would look like this... (remember to make buttons named "download_(foldername).gif" and "download_zip_(foldername).gif" Same thing for the ones with "_off". In my case I made an image called "download_big.gif" and one called "download_off_big.jpg)

Code: [Select]
 $additional_download_sizes = array(800, 1024, 1280, 1600, big);

  $register_array = array();
  foreach ($additional_download_sizes as $size) {
    ereg("(.+)\.(.+)", basename($image_row['image_media_file']), $regs);
    $file = ((is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/" : MEDIA_PATH."/".$image_row['cat_id']."/").$size."/".$regs[1].".".$regs[2];
    if (!$allow_download || !get_file_path($file, "media", $image_row['cat_id'], 0, 0)) {
      $register_array['download_button_'.$size] = "<img src=\"".get_gallery_image("download_off_$size.gif")."\" border=\"0\" alt=\"\" />";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<img src=\"".get_gallery_image("download_zip_off_$size.gif")."\" border=\"0\" alt=\"\" />" : "";
    }
    else {
      $register_array['download_button_'.$size] = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size2=".$size)."\"".$target."><img src=\"".get_gallery_image("download_$size.gif")."\" border=\"0\" alt=\"\" /></a>";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=zip&amp;".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size2=".$size."&amp;size=".$size)."\"><img src=\"".get_gallery_image("download_zip_$size.gif")."\" border=\"0\" alt=\"\" /></a>" : "";
    }
  }
  $site_template->register_vars($register_array);


Now, I can have a folder named big that works with other mod, I also now have the option of having a download button for getting the biggest file placed in the big folder...
I also have the option of having different folders with different sizes, and downloadbuttons for them...

All in all! I am very pleased!

We are here to share... right??

Thanx!
I'm not to good in english (I'm from germany) so I'm not sure if this would be the right modification to do, so I'm asking first:

Is this modification able to create a second download link for images in folder "big" ?
If yes, will the second download link count on statistics?
will it be grayed out if nothing is found in "big" ?

I'm not sure if I understand what this mod above will do ? I already have a mod working to have 3 sizes for 1 image (thumbnail, small showed on detail page, big one in folder big) and right now you will download the big files if you click on the normal download link, but sometimes the files I upload are to small and are not resized and then the "big" folder is empty and download don't work. So I want to change it back and normal download link links to image shown in details and second download link to the one in folder "big".

Thanks a lot, Lunique
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: Lunique on February 18, 2009, 06:20:02 PM
Ok I just tried it myself and it worked as I wanted to but now when I'm using search I get following lines at the top of the page:

Code: [Select]
Notice: Use of undefined constant big - assumed 'big' in /usr/export/www/vhosts/funnetwork/hosting/kellypicturesite/includes/functions.php on line 362The code appears as often as images are shown on this page so If I find 24 images during search I have 24times exactly this line and below the search results
On line 362 starts the code of MrWante with
Code: [Select]
$additional_download_sizes = array(800, 1024, 1280, 1600, big);
any solution?
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: Lunique on February 19, 2009, 01:48:02 PM
I can hide it now with comment out of following line in search.php
Code: [Select]
// error_reporting(E_ALL);
but I would prefer not just to hide it but to fix it
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: V@no on February 19, 2009, 03:16:59 PM
$additional_download_sizes = array(800, 1024, 1280, 1600, "big");
Should do it.
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: Lunique on February 19, 2009, 03:55:48 PM
Yes it does! Thanks a lot!
Title: Re: Different download options / Verschiedene Download Möglichke
Post by: Fastian on March 06, 2009, 07:15:41 PM
Hi V@no

How can I modify the following code of yours so that I can use different buttons on Lightbox page do download different file sizes?
(i.e. files from different folder (800, 1024)

if anyone interesting use different folders for different size images, then here is modifyed mod:
change original mod code to this:
Code: [Select]
 $additional_download_sizes = array(72, 120, 300);

  $register_array = array();
  foreach ($additional_download_sizes as $size) {
    ereg("(.+)\.(.+)", basename($image_row['image_media_file']), $regs);
    $file = ((is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/" : MEDIA_PATH."/".$image_row['cat_id']."/").$size."/".$regs[1].".".$regs[2];
    if (!$allow_download || !get_file_path($file, "media", $image_row['cat_id'], 0, 0)) {
      $register_array['download_button_'.$size] = "<img src=\"".get_gallery_image("download_off.gif")."\" border=\"0\" alt=\"\" />";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<img src=\"".get_gallery_image("download_zip_off.gif")."\" border=\"0\" alt=\"\" />" : "";
    }
    else {
      $register_array['download_button_'.$size] = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size2=".$size."&amp;size=".$size)."\"".$target."><img src=\"".get_gallery_image("download.gif")."\" border=\"0\" alt=\"\" /></a>";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=zip&amp;".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size2=".$size."&amp;size=".$size)."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>" : "";
    }
  }
  $site_template->register_vars($register_array);
I dont know if size= also uses somewhere else, so I just add one more, size2=
so, then open download.php file.
find
Code: [Select]
 if (isset($HTTP_GET_VARS['size']) || isset($HTTP_POST_VARS['size'])) {
    $size = (isset($HTTP_GET_VARS['size'])) ? intval($HTTP_GET_VARS['size']) : intval($HTTP_POST_VARS['size']);
  }
  else {
    $size = 0;
  }
add after:
Code: [Select]
 if (isset($HTTP_GET_VARS['size2']) || isset($HTTP_POST_VARS['size2'])) {
    $size2 = (isset($HTTP_GET_VARS['size2'])) ? intval($HTTP_GET_VARS['size2']) : intval($HTTP_POST_VARS['size2']);
  }
  else {
    $size2 = 0;
  }
then find:
Code: [Select]
   $file['file_path'] = dirname($image_row['image_media_file'])."/".$file['file_name'];
change to this:
Code: [Select]
   $file['file_path'] = dirname($image_row['image_media_file'])."/".(($size2) ? $size2."/" : "").$file['file_name'];
few lines down find:
Code: [Select]
   $file['file_path'] = (is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/".$file['file_name'] : MEDIA_PATH."/".$image_row['cat_id']."/".$file['file_name'];
change to this:
Code: [Select]
   $file['file_path'] = (is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/".(($size2) ? $size2."/" : "").$file['file_name'] : MEDIA_PATH."/".$image_row['cat_id']."/".(($size2) ? $size2."/" : "").$file['file_name'];
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: Fastian on March 11, 2009, 05:21:55 AM
I spent hours trying to find a way to use Lightbox with this Mod of V@no version (Images in diff folders) but no success.
Would certainly appreciate your help :)
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: Eagle Eye on March 19, 2009, 03:49:54 PM
Hello everyone... nice mod.. have a questions:

1) Is it possible to modify the add new images file so that it does not detect anything other than the normal version of image while adding a new image to into database?
2) Can the same be applied to V@no's batch import from zip plugin?
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: lapas on April 11, 2009, 06:27:31 PM
I want to do that, when clicking on the button download 1280x800 returned pages in a new window with that picture, it is better to separate page to have your own set title(example: thisimage 1280x800)
any ideas?
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: Eagle Eye on April 17, 2009, 09:50:49 PM
I am testing this mod (using the gallery for pdf files with gif files as preview in details page) and have modified it in such a way to show file size (of PDF), and the download feature in details.php downloads the pdf version.
the PDF file and its GIF preview are both sored in the same folders. The GIF file is in database and the PDF file is not.

but when i add all the images to a lightbox (i have lightbox for guest by v@no) and then try to download.. the script is zipping and downloading the image previews (GIF files from the details page) and not the required PDF files.

How to mod this, so that i can download both instead of just the image preview?

in short: would like to download both GIF and PDF in a zip file from lightbox.
Title: Re: Different download options / Verschiedene Download Möglichkeiten
Post by: innovationsraum on October 22, 2009, 05:18:45 PM
Hi...

First of all I have to say a big "Thank You" to Jan. I use this mod and it works excellent. I use the mod from Fox Mulder as well to get different Download Buttons.

My regular images are 72dpi and the HighRes Pics are 300dpi. File names of the regular pics for example is "picture001.jpg" and for the same in HigRes "picture001_300.jpg". I upload all pics to a category via FTP and add them to the Database with "Check for new Files" in the Admin Control Panel, but I set the 300 dpi pictures to "active = no". So far so good ;)

I customized my template to get 5 Buttons in the details.html (Lightbox, Download 72dpi, Download 300dpi, ZIP-Download 72dpi and ZIP-Download 300dpi).

Now my question:

Is it possible to have 2 Lightbox Buttons as well ? One to add the 72dpi images (which actually does the "regular" Lightbox Button) and one to add the 300dpi images.

Any help is very welcome