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
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...
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!
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...
$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']."&size2=".$size."&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&".URL_IMAGE_ID."=".$image_row['image_id']."&size2=".$size."&size=".$size)."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>" : "";
}
}
$site_template->register_vars($register_array);
this I changed to...
$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']."&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&".URL_IMAGE_ID."=".$image_row['image_id']."&size2=".$size."&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 ."&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)
$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']."&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&".URL_IMAGE_ID."=".$image_row['image_id']."&size2=".$size."&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