[MOD] Multi download size ver 4.7This MOD will allow your users to download multiple different sizes of one image.
see the attached screenshot to see what it looks like.
* You can modify the sizes in the Global.php file to set the range you want your users to download.
* Added variables in the global.php file for easy customizing of mod for your site.
(New to ver 2.1)* Added variables that you can now set crop settings to get actual size when resizing
(New to ver 3.0)* You can now have text links and image links instead of dropdown list
(New to ver 2.1)* You can select if the catagory uses this option or the normal download/zip option instead.
* You can set the category to only allow sizes smaller then original to be downloaded
(New to ver 2.0)* Original file is an option on the list, if your user does not want it resized.
(New to ver 2.0)* You only need to upload one size of the file and the server will do the rest for you (I am lazy)
all the other mods I saw wanted you to create all the different sizes before you uploaded them.
This mod will create the resized images at the time the user is asking for them.
* Also, if nobody ever downloads a 640X480 image then you do not have the extra images on your server.
* The MOD does check to see if it already created the size so it does not have to create it twice.
* If file is not an image you will get the normal download button instead.
(New to ver 3.1)* You can now group the button/links/dropdown for easier navigation.
(New to ver 4.0)* Now instead of downloading the images, you can have a popup window instead if you choose.
(New to ver 4.0)* Have added where it will detect the users screen resolution for easier choosing.
(New to ver 4.0)* added more selections in default list for mobile phones
(New to ver 4.0)* added exact ratio selection taken from original file for size selections. is turned off by default
(New to ver 4.2)* added a template for popup window
(New to ver 4.4)I was having a hard time creating a way to remove the extra files if you delete images/or move them.
I wound up just making a plugin that you run in the admin cp that will erase all resized images from the server.
This MOD was tested on a fresh install of 1.7.11 and everything worked fineChanges made in Version 4.7--Fixed a problem where not downloading on mobile devices using the dropdown list.
Changes made in Version 4.6--Fixed a problem where not displaying image name in popup window.
Changes made in Version 4.5--Fixed a problem where it was pulling the sizes from the random image instead of the main image on detail page
Changes made in Version 4.4--I fixed a division by 0 error warning that I was getting with this mod.
--Added template for popup window.
--Added annotation link to resized image (if using that mod)
Changes made in Version 4.3--I had a major problem with dealing with sessions on my links. They are repaired on this release.
--Good news, you only have to replace the insert in the includes/functions.php file to fix this error.
backup your database in case something goes wrong and also backup these files before you proceed.I would also suggest using it on a testing site and not your main one in case something crashesThese are the files that will be modified...
details.php
download.php
global.php
admin/categories.php
includes/constants.php
includes/functions.php
lang/english/admin.php
lang/english/main.php
template/your template you are using/details.html
The zip file attached contains the plugin and the installer and the graphic buttons for your site.
The plugin needs to be placed in the
admin/plugins folder
place the multi_download_install.php in your root folder of your gallery and run it once so it can install the
new multi_download field into your categories table.
Make sure you delete it afterward for security.
in the
global.php file
look for
$sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
replace with
$sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, multi_download
look for
?>
insert
Before (changed in version 2) (updated in version 4.0) (updated in version 4.2)// MOD multi download
$download_multi_sizes= array(
array('group1',0,0), //Groups are created in this format, group1 name is associated with a language entry with the same name (the 0,0 is important!)
array('800x600',800,600),
array('1024x768',1024,768),
array('1280x960',1280,960),
array('1400x1050',1400,1050),
array('1600x1200',1600,1200),
array('2048x1536',2048,1536),
array('group2',0,0),
array('1280x720',1280,720),
array('1366x768',1366,768),
array('1920x1080',1920,1080),
array('2560x1440',2560,1440),
array('group3',0,0),
array('1280x800',1280,800),
array('1440x900',1440,900),
array('1680x1050',1680,1050),
array('1920x1200',1920,1200),
array('2560x1600',2560,1600),
array('group4',0,0),
array('96x65',96,65),
array('101x80',101,80),
array('128x128',128,128),
array('128x160',128,160),
array('174x132',174,132),
array('240x320',240,320),
array('group5',0,0),
array('240x160',240,160),
array('240x260',240,260),
array('240x240',240,240),
array('320x240',320,240)
);
// the first field is the name that is shown in the list that you choose from
// the second field is the width
// the third field is the height
$multi_download_var['type'] = 0; //0=dropdown, 1=text links, 2=image links
$multi_download_var['columns'] = 4; // #of columns in table for links, not used for dropdown
$multi_download_var['button']="gif"; //type of file for your image link buttons gif,jpg,png
$multi_download_var['bold_groups']=1; //Bold option group labels (only for text links and buttons), 1=yes, 0=no
$multi_download_var['center_groups']=1; //Center option group labels (only for text links and buttons), 1=yes, 0=no
$multi_download_var['show_resolution']=1;// Display user's display resolution, 1=yes, 0=no
$multi_download_var['download']=1; //display "select size to download at top of table" 1=yes, 0=no
$multi_download_var['table']=220; //width of table that will house this MOD, 220 is good for dropdown, 420 is good for others
$multi_download_var['show_table']=1; //show border and shading in back of MOD, 1=yes,0=no
$multi_download_var['show_original']=1; //display "original image" as an option 1=yes, 0=no
$multi_download_var['newline_original']=1; //place 'original size' button on its own line, 1=yes, 0=no
$multi_download_var['center_original']=1; //center 'original size' button with space that is left in row, 1=yes, 0=no
$multi_download_var['alt_image']=1; //Use Alt variable with image links, 1=yes,0=no
$multi_download_var['crop']=0; //crop image after resize (see below)
/* what crop will do is resize image larger then size that is asked for unless it detects it will resize without and extra space.
then it will crop off the extra area to give you the actual size asked for (loosing part of your image)
0= do not crop
1= crop equally on both sides
2= crop top or left side
3= crop bottom or right side
4= resize and stretch to fit requested size (no crop)
*/
$multi_download_var['quality']= 90; //quality settings for resizing/cropping 10-100 (10=high compression, 100= lowest compression)
$multi_download_var['target']="";// for popup window instead of download replace the quote with "TARGET = '_blank' "
// You can also replace _blank with a name like mypopup and then all images will open in same popup window
$multi_download_var['ratio']=0; //Only sizes that fit size ratio of original will be available (must be exact match on ratio!)
// END MOD multi download
this was the original insert for removal purposes if upgrading from beta to ver 2 or above// MOD multi download
$download_multi_sizes= array(
array('640X480',640,480),
array('800X600',800,600),
array('1024X768',1024,768),
array('1280X960',1280,960),
array('1400X1050',1400,1050),
array('1600X1200',1600,1200),
array('1280X800-wide',1280,800),
array('1440X900-wide',1440,900),
array('1680X1050-wide',1680,1050),
array('1920X1200-wide',1920,1200)
);
// the first field is the name that is shown in the list that you choose from
// the second field is the width
// the third field is the height
$multi_download_options_string="<BR><BR>
<form action='".ROOT_PATH.'download.php'."' method='post'>
<table border='0' cellspacing='1' cellpadding='0' width='210' class='head1'>
<tr><td><table border='0' cellspacing='0' cellpadding='0' width='210' class='row2'><tr>
<td colspan='2' align='center'>".$lang['multi_select']."</TD></TR>
<TR class='row1'><TD><select name='multi_download_select'>";
$var=0;
while ($var < count($download_multi_sizes)){
$multi_download_options_string .="<option value='".$var."'>".$download_multi_sizes[$var][0]."</option>";
$var = $var +1;
}
$multi_download_options_string .="</select>";
// END Multi Download
in the
admin/categories.php file
look for
$access_array = array(
AUTH_ALL => $lang['all'],
AUTH_USER => $lang['userlevel_registered'],
AUTH_ACL => $lang['private'],
AUTH_ADMIN => $lang['userlevel_admin']
);
insert
after (new for ver2.0)// MOD multi download
function show_radio_row_multi($title, $name, $value = 0) {
global $HTTP_POST_VARS, $lang, $multi_download_optionlist;
if (isset($HTTP_POST_VARS[$name])) {
$value = $HTTP_POST_VARS[$name];
}
echo "<tr class=\"".get_row_bg()."\">\n";
echo "<td><p class=\"rowtitle\">".$title."</p></td>\n<td><p>";
foreach ($multi_download_optionlist as $key => $val) {
echo "<input type=\"radio\" name=\"".$name."\" value=\"$key\"";
if ($value == $key) {
echo " checked=\"checked\"";
}
echo "> ".$val."<br />";
}
echo "</p></td>\n</tr>";
}
// END MOD multi download
look for
2 times
$auth_postcomment = $HTTP_POST_VARS['auth_postcomment'];
insert after
Both places
// MOD Multi Download
$multi_download = (isset($HTTP_POST_VARS['multi_download'])) ? intval($HTTP_POST_VARS['multi_download']) : 0;
// END MOD Multi download
look for
(cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
replace with
(cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, multi_download
look for
('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment
replace with
('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment, $multi_download
look for
$permission_headline = $lang['permissions'];
insert
before (changed insert for ver 2.0)// MOD multi download
$value = intval($cat_row['multi_download']);
show_radio_row_multi($lang['multi_option'],'multi_download',$value);
// END MOD multi download
look for
$sql = "SELECT cat_name, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
replace with
$sql = "SELECT cat_name, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, multi_download
look for
SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment
replace with
SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment, multi_download = $multi_download
look for
$sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
replace with
$sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, multi_download
look for
show_table_separator($lang['permissions'], 2);
insert
before (changed insert for ver 2.0)// MOD multi download
$value = intval($cat_row['multi_download']);
show_radio_row_multi($lang['multi_option'],'multi_download',$value);
// END MOD multi download
in the
details.php file
look for
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_email")."
replace with
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_email").", c.multi_download
look for
$is_image_owner = ($image_row['user_id'] > USER_AWAITING && $user_info['user_id'] == $image_row['user_id']) ? 1 : 0;
insert
after (Updated insert for ver 3.1)// MOD multi download
$multi_download = $image_row['multi_download'];
if($multi_download){
if(!strpos(",jpg,jpeg,JPG,JPEG,png,gif",pathinfo($image_row['image_media_file'], PATHINFO_EXTENSION))){
$multi_download=0;
}
}
// END MOD multi download
look for
//-----------------------------------------------------
//---Clickstream---------------------------------------
//-----------------------------------------------------
insert
before//MOD multi download
if (!$multi_download){
$site_template->register_vars("yes_multi_download", 0);
$site_template->register_vars("not_multi_download", 1);
}
else{
$site_template->register_vars("yes_multi_download", 1);
$site_template->register_vars("not_multi_download", 0);
}
//END MOD multi download
in the
download.php file
look for
$sql = "SELECT image_id, cat_id, user_id, image_media_file, image_download_url, image_downloads
FROM ".IMAGES_TABLE."
WHERE image_id = $image_id AND image_active = 1";
$image_row = $site_db->query_firstrow($sql);
insert
before (updated insert for version 2.1)// MOD multi download
if ($_POST['action'] == "resize" || $_GET['action'] == "resize"){
$multi_download_select = (isset($HTTP_GET_VARS['multi_download_select'])) ? intval($HTTP_GET_VARS['multi_download_select']) : intval($HTTP_POST_VARS['multi_download_select']);
$size = MULTI_DOWNLOAD_SEP.$download_multi_sizes[$multi_download_select][0];
}
// END MOD multi download
Also on the first line of the "look for" code above
(new replace for version 4.4)add new code to the end of the first line so it looks like this
(Updated the code for version 4.6) $sql = "SELECT image_id, cat_id, user_id, image_media_file, image_download_url, image_downloads, image_keywords, image_description, image_name
look for
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);
insert
before (Updated insert for ver 3.0)(Updated insert for ver 4.4)// MOD multi download
if ($size){
$multi_resize=get_file_path($regs[1].'.'.$regs[2], "big", $image_row['cat_id'], 0, 1);
if (!file_exists($multi_resize)){
$multi_resize = (is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/".$regs[1].'.'.$regs[2] : MEDIA_PATH."/".$image_row['cat_id']."/".$regs[1].'.'.$regs[2];
}
$file['file_name'] = $file_name.(($size) ? "_".$size : "").".".$file_extension;
$multi_new_image=(is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/".MULTI_BIG_FOLDER."/".$file['file_name'] : MEDIA_PATH."/".$image_row['cat_id']."/".MULTI_BIG_FOLDER."/".$file['file_name'];
$file['file_path'] = $multi_new_image;
$multi_dir=dirname($multi_new_image);
if (!file_exists($multi_new_image)){
if (!@is_dir($multi_dir)){
$oldumask = umask(0);
$result = mkdir($multi_dir);
umask($oldumask);
if (!@is_dir($multi_dir) || !$result) {
$result = mkdir($multi_dir, 0755);
}
}
$multi_var = multi_download_resize($multi_resize,$multi_new_image,$multi_download_var['quality'],$download_multi_sizes[$multi_download_select][1],$download_multi_sizes[$multi_download_select][2]);
if ($multi_var !== $multi_resize){
$file['file_path'] = $multi_new_image;
//-------------------------------------------------------------------------------------------
// --- Annotate Resized Images ----------------------------------------------------------------------
//-------------------------------------------------------------------------------------------
if ($config['annotation_use'] && strtolower($file_extension == jpg)) {
require(ROOT_PATH.'includes/annotate.php');
$ann_user_name = ($user_info['user_name']);
annotate_image($file['file_path']);
}
//-------------------------------------------------------------------------------------------
}
else {
$file['file_name'] = $file_name.".".$file_extension;
$file['file_path'] = $multi_resize;
}
}
}
// END MOD multi download
look for
(New for ver 4.0- only needed if you want a popup window instead of download)(Updated for V4.4 to include template)send_file($file['file_name'], $file['file_path']);
Replace with
(Updated in V4.6)//MOD multi download for popup window
if (($multi_download_var['target']<>"") && $size){
$meta_keywords = !empty($image_row['image_keywords']) ? implode(", ", explode(",", $image_row['image_keywords'])) : "";
$meta_description = !empty($image_row['image_description']) ? strip_tags($image_row['image_description']) . ". " : "";
$image_name = format_text($image_row['image_name'], 2);
$site_template->register_vars(array(
"img_url" => $file["file_path"],
"site_name" => $config['site_name'],
"charset" => $lang['charset'],
"direction" => $lang['direction'],
"detail_meta_description" => $meta_description,
"detail_meta_keywords" => $meta_keywords,
"prepend_head_title" => $image_name . " - "
));
$site_template->print_template($site_template->parse_template("multi_popup"));
}
else{
send_file($file['file_name'], $file['file_path']);
}
//END MOD multi download for popup window
in the
includes\constants.php file
look for
?>
insert
before// MOD multi download
define ('MULTI_BIG_FOLDER' , 'big'); //This is the name of the 'big' folder or the name of a seperate subfolder for resizing of images.
define ("MULTI_DOWNLOAD_SEP","_resized_");//an underscore will be added to this variable before it is attached (which in this case will make 2 underscores)
//this is what this Mod uses as a seperator from all the files it creates on your server.
// the format will be 'yourfilename_ (whatever the sep is set for)(and the names of your option for that size).jpg'
//example: if I have an option for 1024X768 the new name would be 'yourfilename__resized_1024X768.jpg' notice the 2 underscores in a row at the beginning, one is built in and the other is an option that you can take away if needed.
//NOTE: when this mod is cleaning up it is looking for any file with '_ (whatever the sep is set for)' [example '__resized_'] is what the mod is looking for, (notice the 2 underscores in a row at the beginning)
// I am assuming that you will not EVER have '__resized_' in any of your normal filenames, if you do, then you need to change the SEP variable to something that you will never use in a filename or you can have the MOD store the
// resized images in a different subfolder then the 'big' folder that is above and then the seperator will not matter. The Mod will create the new subfolder on the fly while it is running.
// END MOD multi download
in the
includes\functions.php file
look for
function show_image($image_row, $mode = "", $show_link = 1, $detailed_view = 0) {
global $self_url, $site_template, $site_sess, $user_info, $config, $cat_cache, $lang, $additional_image_fields, $user_table_fields, $url_show_profile;
insert
after (changed insert for ver 2.0) (updated insert for ver 2.1) global $download_multi_sizes, $multi_download_var, $site_db;// MOD multi download
original insert that needs replaced if upgrading from beta to ver 2.0 global $multi_download_options_string;// MOD multi download
ONLY ADD THIS MODIFICATION IF IT IS NOT ALREADY THERE FROM THE BIG MOD! (NEW TO VER 2.0 and above) look for
$check_handle = "check_".$image_type."_type";
$path = (($image_type == "media") ? (($cat_id) ? MEDIA_PATH."/".$cat_id : MEDIA_TEMP_PATH) : (($cat_id) ? THUMB_PATH."/".$cat_id : THUMB_TEMP_PATH))."/".$file_name;
return ($check_handle($file_name) && file_exists($path)) ? (($in_admin && !preg_match("#(gif|jpg|jpeg|png)$#is", $file_name)) ? ICON_PATH."/".get_file_extension($file_name).".gif" : $path) : $return_code;
replace with
// MOD multi download (with needed info for big directory if not using that mod)
$check_handle = "check_".$image_type."_type";
// $path = (($image_type == "media") ? (($cat_id) ? MEDIA_PATH."/".$cat_id : MEDIA_TEMP_PATH) : (($cat_id) ? THUMB_PATH."/".$cat_id : THUMB_TEMP_PATH))."/".$file_name;
// return ($check_handle($file_name) && file_exists($path)) ? (($in_admin && !preg_match("#(gif|jpg|jpeg|png)$#is", $file_name)) ? ICON_PATH."/".get_file_extension($file_name).".gif" : $path) : $return_code;
// Download file block insert BEGIN
switch( $image_type ) {
case "media":
if( $cat_id ){
$path = MEDIA_PATH."/".$cat_id;
}else{
$path = MEDIA_TEMP_PATH;
}
break;
case "big":
$path = MEDIA_PATH."/".$cat_id."/big";
break;
case "download":
$path = MEDIA_PATH."/".$cat_id."/download";
break;
default:
if( $cat_id ){
$path = THUMB_PATH."/".$cat_id;
}else{
$path = THUMB_TEMP_PATH;
}
break;
}
$path .= "/".$file_name;
// Download file block insert END
return ($check_handle($file_name) && file_exists($path)) ? (($in_admin && !preg_match("#(gif|jpg|jpeg|png)$#is", $file_name)) ? ICON_PATH."/".get_file_extension($file_name).".gif" : $path) : (($image_type != "big" && $image_type != "big") ? $return_code : ""); // Download file :: V@no big mod
// END MOD multi download (with needed info for big directory if not using that mod)
look for
(new to ver 2.0)(Changed in ver 4.5, read this posthttp://www.4homepages.de/forum/index.php?topic=22741.msg163311;topicseen#msg163311 ) $rate_form = "";
if (check_permission("auth_vote", $image_row['cat_id'])) {
$site_template->register_vars("rate", $lang['rate']);
$rate_form = $site_template->parse_template("rate_form");
}
$site_template->register_vars("rate_form", $rate_form);
$site_template->register_vars(array(
"image" => get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, $detailed_view),
));
insert
After (updated insert for ver 3.1) (updated for ver 4.1) (updated for ver 4.2)(updated/repaired for ver 4.3)(updated for ver 4.5)(updated for ver 4.7)// MOD multi download
if ($detailed_view){
$sql = "SELECT multi_download
FROM ".CATEGORIES_TABLE."
WHERE cat_id = ".$image_row['cat_id']." ";
$result = $site_db->query_firstrow($sql);
$multi_download = $result['multi_download'];
}
if ($multi_download && $detailed_view){
if (!check_permission("auth_download", $image_row['cat_id'])) {
$multi_download_options=" <img src=\"".get_gallery_image("download_off.gif")."\" border=\"0\" alt=\"\" />";
$allow_download = 0;
clear_download_token($image_row['image_id']);
}
else{
$multi_download_colvar = 0;
if ($multi_download_var['show_table']){
$multi_download_class1 = "class='head1'";
$multi_download_class2 = "class='row1'";
$multi_download_class3 = "class='row2'";
}
else {
$multi_download_class1 = "";
$multi_download_class2 = "";
$multi_download_class3 = "";
}
$multi_download_group0 = ($multi_download_var['center_groups'] ? "align='center'" : "");
// change the code below to change how your monitor resolution is displayed
$multi_download_resolution = "<TR ".$multi_download_class3."><TD colspan='".$multi_download_var['columns']."' align='center'><B>".$lang['multi_resolution']."<script type='text/javascript'>document.write(screen.width+'X'+screen.height)</script></B></TD></TR>";
if ($multi_download_var['bold_groups']){
$multi_download_group1= "<B>";
$multi_download_group2= "</B>";
}
else{
$multi_download_group1= "";
$multi_download_group2= "";
}
if (!$multi_download_var['type']){
$multi_download_options = "<BR><BR><form action='".$site_sess->url(ROOT_PATH."download.php")."' method='get'".$multi_download_var['target']."><table border='0' cellspacing='1' cellpadding='0' width='".$multi_download_var['table']."' ".$multi_download_class1."><tr><td><table border='0' cellspacing='0' cellpadding='0' width='".$multi_download_var['table']."'>";
if ($multi_download_var['show_resolution']){
$multi_download_options .= $multi_download_resolution;
}
if ($multi_download_var['download']){
$multi_download_options .="<TR ".$multi_download_class3."><TD colspan='".$multi_download_var['columns']."' align='center'>".$lang['multi_select']."</TD></TR>";
}
$multi_download_options .="<TR ".$multi_download_class2."><TD><select name='multi_download_select'>";
}
else{
$multi_download_options = "<table border='0' cellspacing='1' cellpadding='0' width='".$multi_download_var['table']."' ".$multi_download_class1."><tr><td><table border='0' cellspacing='0' cellpadding='0' width='".$multi_download_var['table']."'>";
if ($multi_download_var['show_resolution']){
$multi_download_options .= $multi_download_resolution;
}
if ($multi_download_var['download']){
$multi_download_options .= "<tr ".$multi_download_class3."><TD colspan='".$multi_download_var['columns']."' align='center'>".$lang['multi_select']."</TD>";
}
}
$var=0;
$down_group=0;
$down_group_flag=0;
$multi_download_group="";
$multi_download_colvar=0;
if (ISSET($site_template->val_cache['download_width'])){
$max_width = $site_template->val_cache['download_width'];
$max_height = $site_template->val_cache['download_height'];
}
else {
$max_width = $site_template->val_cache['width'];
$max_height = $site_template->val_cache['height'];
}
$varcount= count($download_multi_sizes);
while ($var < $varcount){
if ($download_multi_sizes[$var][1] == '0'){
if ((!$down_group) && ($multi_download_group<>"")){
if (!$multi_download_var['type']) {
$multi_download_options .=$multi_download_group;
}
else{
if ($multi_download_colvar < $multi_download_var['columns']){
$multi_download_colvar1=($multi_download_var['columns'] - $multi_download_colvar);
$multi_download_group .= "<td align='center' colspan='".$multi_download_colvar1."'></td>";
}
$multi_download_options .= "<tr ".$multi_download_class2.">".$multi_download_group."</tr>";
}
}
if ($down_group && $down_group_flag){
if (!$multi_download_var['type']) {
$multi_download_group .= "</optgroup>";
}
else{
if ($multi_download_colvar < $multi_download_var['columns']){
$multi_download_colvar1=($multi_download_var['columns'] - $multi_download_colvar);
$multi_download_group .= "<td align='center' colspan='".$multi_download_colvar1."'></td>";
}
}
$multi_download_options .= $multi_download_group;
}
$down_group=1;
$down_group_flag=0;
if (!$multi_download_var['type']) {
$multi_download_group ="<optgroup label='".$lang['multi_down_'.$download_multi_sizes[$var][0]]."'>";
}
else{
$multi_download_group ="</tr><tr ".$multi_download_class3."><td colspan='".$multi_download_var['columns']."' ".$multi_download_group0.">".$multi_download_group1.$lang['multi_down_'.$download_multi_sizes[$var][0]].$multi_download_group2."</TD></TR><tr ".$multi_download_class2.">";
$multi_download_colvar = 0;
}
}
else{
if ((($download_multi_sizes[$var][1] <= $max_width && $download_multi_sizes[$var][2] <= $max_height)&&($multi_download =='2'))||($multi_download=='1')){
if (((($max_width/$max_height)==($download_multi_sizes[$var][1]/$download_multi_sizes[$var][2]))&&($multi_download_var['ratio']))||(!$multi_download_var['ratio'])){
switch($multi_download_var['type']){
case (1) :
$multi_download_group .="<td align='center'><a href='".$site_sess->url(ROOT_PATH."download.php?action=resize&".URL_IMAGE_ID."=".$image_row['image_id']."&multi_download_select=".$var)."'".$multi_download_var['target'].">".$download_multi_sizes[$var][0]."</a></td>";
break;
case (2) :
$multi_download_group .="<td align='center'><a href='".$site_sess->url(ROOT_PATH."download.php?action=resize&".URL_IMAGE_ID."=".$image_row['image_id']."&multi_download_select=".$var)."'".$multi_download_var['target']."><img src='".get_gallery_image($download_multi_sizes[$var][0].".".$multi_download_var['button'])."' ";
if ($multi_download_var['alt_image']){
$multi_download_group .= "alt='".$download_multi_sizes[$var][0]."' ";
}
$multi_download_group .="border='0'></a></td>";
break;
case (0) :
default:
$multi_download_group .="<option value='".$var."'>".$download_multi_sizes[$var][0]."</option>";
break;
}
$down_group_flag=1;
$multi_download_colvar++;
}
}
if (($multi_download_colvar == $multi_download_var['columns']) && ($multi_download_var['type']>0)){
$multi_download_colvar = 0;
$multi_download_group .="</tr><tr ".$multi_download_class2.">";
}
}
$var++;
}
if (($down_group==1) && (!$multi_download_var['type'])){
$multi_download_group .="</optgroup>";
}
if($down_group_flag){
$multi_download_options .=$multi_download_group;
}else{
$multi_download_colvar = 1;
}
$multi_download_colvar2= $multi_download_colvar;
$multi_download_colvar = $multi_download_var['columns'] - $multi_download_colvar;
if ($multi_download_var['center_original']){
$multi_download_colvar1= $multi_download_colvar;
}
else{
$multi_download_colvar1= 1;
$multi_download_colvar--;
}
switch ($multi_download_var['type']){
case(1):
if ($multi_download_var['newline_original']){
if ($multi_download_colvar2){
$multi_download_colvar1 = $multi_download_var['columns'] - $multi_download_colvar2;
$multi_download_options .="<td align='center' colspan='".$multi_download_colvar1."'></td>";
$multi_download_options .="</tr><tr ".$multi_download_class2.">";
}
if ($multi_download_var['center_original']){
$multi_download_colvar1=$multi_download_var['columns'];
}
else{
$multi_download_colvar1 =1 ;
$multi_download_colvar=$multi_download_var['columns'];
}
}
$multi_download_options .="<td align='center' colspan='".$multi_download_colvar1."'>";
if ($multi_download_var['show_original']){
$multi_download_options .= "<a href='".$site_sess->url(ROOT_PATH."download.php?action=resize&".URL_IMAGE_ID."=".$image_row['image_id']."&multi_download_select=".$var)."' ".$multi_download_var['target'].">".$lang['original_size']."</a>";
}
$multi_download_options .= "</td>";
if (!$multi_download_var['center_original']){
$multi_download_options .= "<td colspan='".$multi_download_colvar."'></td>";
}
$multi_download_options .="</tr></table></td></tr></table>";
break;
case(2):
if ($multi_download_var['newline_original']){
if ($multi_download_colvar2){
$multi_download_colvar1 = $multi_download_var['columns'] - $multi_download_colvar2;
$multi_download_options .="<td align='center' colspan='".$multi_download_colvar1."'></td>";
$multi_download_options .="</tr><tr ".$multi_download_class2.">";
}
if ($multi_download_var['center_original']){
$multi_download_colvar1=$multi_download_var['columns'];
}
else{
$multi_download_colvar1 =1 ;
$multi_download_colvar=$multi_download_var['columns'];
}
}
$multi_download_options .="<td align='center' colspan='".$multi_download_colvar1."'>";
if ($multi_download_var['show_original']){
$multi_download_options .= "<a href='".$site_sess->url(ROOT_PATH."download.php?action=resize&".URL_IMAGE_ID."=".$image_row['image_id']."&multi_download_select=".$var)."' ".$multi_download_var['target']."><img src='".get_gallery_image("original_size.".$multi_download_var['button'])."' ";
if($multi_download_var['alt_image']){
$multi_download_options .= "alt='".$lang['original_size']."' ";
}
$multi_download_options .="border='0'></a>";
}
$multi_download_options .= "</td>";
if (!$multi_download_var['center_original']){
$multi_download_options .= "<td colspan='".$multi_download_colvar."'></td>";
}
$multi_download_options .="</tr></table></td></tr></table>";
break;
case(0):
default:
if ($multi_download_var['show_original']){
$multi_download_options .="<option value='".$var."'>".$lang['original_size']."</option>";
}
$multi_download_options .="</select>";
$multi_download_options .= "</td><td><input type='submit' name='download' value='".$lang['download']."' class='button' />
</TD></TR></TABLE></TABLE><input type='hidden' name='action' value='resize' />
<input type='hidden' name='image_id' value='".$image_row['image_id']."' /></form>";
break;
}
$allow_download = 1;
set_download_token($image_row['image_id']);
}
$site_template->register_vars("multi_download_options", $multi_download_options);
unset($multi_download_options);
}
// END MOD multi download
look for
(this insert no longer needed in ver 2.0 or above) (left here so upgrade users can delete) if (!check_permission("auth_sendpostcard", $image_row['cat_id'])) {
insert
before(remove this insert if upgrading from beta to ver 2.0)// MOD multi download
if (!check_permission("auth_download", $image_row['cat_id'])) {
$multi_download_options=" <img src=\"".get_gallery_image("download_off.gif")."\" border=\"0\" alt=\"\" />";
$allow_download = 0;
clear_download_token($image_row['image_id']);
}
else{
$multi_download_options = $multi_download_options_string;
$multi_download_options .= "</td><td><input type='submit' name='download' value='".$lang['download']."' class='button' />
</TD></TR></TABLE></TABLE><input type='hidden' name='action' value='resize' />
<input type='hidden' name='image_id' value='".$image_row['image_id']."' /></form>";
//
$allow_download = 1;
set_download_token($image_row['image_id']);
}
$site_template->register_vars("multi_download_options", $multi_download_options);
// END MOD multi download
look for
?>
insert
before (updated insert for ver 3.1)// MOD multi download
function multi_download_resize($file, $new_file, $quality, $resize_width, $resize_height) {
global $convert_options,$download_multi_sizes,$multi_download_var;
if (!function_exists(init_convert_options)) {
require(ROOT_PATH.'includes/image_utils.php');
}
$convert_options = init_convert_options();
$image_info = (defined("IN_CP")) ? getimagesize($file) : @getimagesize($file);
if (!$image_info) {
return false;
}
if ($resize_width==0){$resize_width=$image_info[0];}
if ($resize_height==0){$resize_height=$image_info[1];}
if ($multi_download_var['crop']){
$scale = max($resize_width/$image_info[0], $resize_height/$image_info[1]);
}
else{
$scale = min($resize_width/$image_info[0], $resize_height/$image_info[1]);
}
$new_width = floor($scale*$image_info[0]);
$new_height = floor($scale*$image_info[1]);
$resize_handle = "resize_image_".$convert_options['convert_tool'];
if ((($scale == '1' || $scale == '0') && !$multi_download_var['crop']) || (($resize_width==$image_info[0]) && ($resize_height==$image_info[1]))){
return $file;
}
if (!$multi_download_var['crop']){
if($resize_handle($file, $new_file, $quality, $new_width, $new_height, $image_info)) {
@chmod($new_file, CHMOD_FILES);
return true;
}
else {
return false;
}
}
$crop_handle = "multi_download_resize_crop_image_".$convert_options['convert_tool'];
if ($resize_width == $new_width){
$multi_crop_st_w='0';
$multi_crop_end_w=$image_info['0'];
$multi_crop_end_h = (($image_info['0']*$resize_height)/$resize_width);
switch($multi_download_var['crop']){
case (2) :
$multi_crop_st_h= ($image_info['1']-$multi_crop_end_h);
break;
case (3) :
$multi_crop_st_h= '0';
break;
case (4) :
$multi_crop_st_h = '0';
$multi_crop_end_h = $image_info[1];
break;
case (1) :
default:
$multi_crop_st_h= (($image_info['1']-$multi_crop_end_h)/2);
break;
}
}
else{
$multi_crop_st_h='0';
$multi_crop_end_h=$image_info['1'];
$multi_crop_end_w = (($image_info['1']*$resize_width)/$resize_height);
switch($multi_download_var['crop']){
case (2) :
$multi_crop_st_w= ($image_info['0']-$multi_crop_end_w);
break;
case (3) :
$multi_crop_st_w= '0';
break;
case (4) :
$multi_crop_st_w = '0';
$multi_crop_end_w = $image_info[0];
break;
case (1) :
default:
$multi_crop_st_w = (($image_info['0']-$multi_crop_end_w)/2);
break;
}
}
if($crop_handle($file, $new_file, $quality, $resize_width, $resize_height, $image_info, $multi_crop_st_w,$multi_crop_st_h,$multi_crop_end_w,$multi_crop_end_h)) {
@chmod($new_file, CHMOD_FILES);
return true;
}
else {
return false;
}
}
function multi_download_resize_crop_image_gd($src, $dest, $quality, $width, $height, $image_info, $multi_crop_st_w, $multi_crop_st_h, $multi_crop_end_w, $multi_crop_end_h) {
global $convert_options,$multi_download_var;
$types = array(1 => "gif", 2 => "jpeg", 3 => "png");
if ($convert_options['convert_gd2']) {
$thumb = imagecreatetruecolor($width, $height);
}
else {
$thumb = imagecreate($width, $height);
}
$image_create_handle = "imagecreatefrom".$types[$image_info[2]];
if ($image = $image_create_handle($src)) {
if ($convert_options['convert_gd2']) {
imagecopyresampled($thumb, $image, 0, 0, $multi_crop_st_w,$multi_crop_st_h, $width, $height, $multi_crop_end_w, $multi_crop_end_h);
}
else {
imagecopyresized($thumb, $image, 0, 0, $multi_crop_st_w,$multi_crop_st_h, $width, $height, $multi_crop_end_w, $multi_crop_end_h);
}
if ($image_info[2] == 3) {
$quality = 9;
}
$image_handle = "image".$types[$image_info[2]];
$image_handle($thumb, $dest, $quality);
imagedestroy($image);
imagedestroy($thumb);
}
return (file_exists($dest)) ? 1 : 0;
}
function multi_download_resize_crop_image_im($src, $dest, $quality, $width, $height, $image_info, $multi_crop_st_w, $multi_crop_st_h, $multi_crop_end_w, $multi_crop_end_h) {
global $convert_options,$multi_download_var;
if ($multi_download_var['crop']==4){
$command = $convert_options['convert_path'];
$command .= " \"$src\" -quality ".$quality." -antialias -geometry $width"."x"."$height! -profile '*' -unsharp 0.5x1 \"$dest\"";
}
else{
$command = $convert_options['convert_path'];
$command .= " \"$src\" -crop ".$multi_crop_end_w."X".$multi_crop_end_h."+".$multi_crop_st_w."+".$multi_crop_st_h;
$command .= " -quality ".$quality." -antialias -geometry $width"."x"."$height -profile '*' -unsharp 0.5x1 \"$dest\"";
}
system($command);
return (file_exists($dest)) ? 1 : 0;
}
function multi_download_resize_crop_image_netpbm($src, $dest, $quality, $width, $height, $image_info, $multi_crop_st_w,$multi_crop_st_h,$multi_crop_end_w,$multi_crop_end_h) {
global $convert_options,$multi_download_var;
$convert_path = $convert_options['convert_path'];
$types = array(1 => "gif", 2 => "jpeg", 3 => "png");
$target = ($width > $height) ? $width : $height;
$command = $convert_path."/".check_executable($types[$image_info[2]]."topnm")." ".$src." | ";
if ($multi_download_var['crop']==4){
$command .= $convert_path."/".check_executable("pnmscale")." --quiet -xsize=".$width." -ysize=".$height." | ";
}
else{
$command .= $convert_path."/".check_executable("pnmcut")." --quiet ".$multi_crop_st_w." ".$multi_crop_st_h." ".$multi_crop_end_w." ".$multi_crop_end_h." | ";
$command .= $convert_path."/".check_executable("pnmscale")." --quiet -xysize ".$width." ".$height." | ";
}
if ($image_info[2] == 1) {
$command .= $convert_path."/".check_executable("ppmquant")." 256 | " . $convert_path."/".check_executable("ppmtogif")." > ".$dest;
}
elseif ($image_info[2] == 3) {
$command .= $convert_path."/".check_executable("pnmtopng")." > ".$dest;
}
else {
$jpeg_exec = (file_exists($convert_path."/".check_executable("pnmtojpeg"))) ? check_executable("pnmtojpeg") : check_executable("ppmtojpeg");
$command .= $convert_path."/".$jpeg_exec." --quality=".$quality." > ".$dest;
}
system($command);
return (file_exists($dest)) ? 1 : 0;
}
if (!function_exists('check_big_type')) {
function check_big_type($file_name) {
global $config;
return (in_array(get_file_extension($file_name), $config['allowed_mediatypes_array'])) ? 1 : 0;
}
function check_remote_big($remote_media_file) {
global $config;
return (preg_match("#^(https?:\/\/[a-z0-9\-]+?\.([a-z0-9\-]+\.)*[a-z]+(:[0-9]+)*\/.*?\.(".$config['allowed_mediatypes_match'].")$)#is", $remote_media_file)) ? 1 : 0;
}
function check_local_big($local_media_file) {
global $config;
return (preg_match("#^((\.)*\/.*?\.(".$config['allowed_mediatypes_match'].")$)#is", $local_media_file)) ? 1 : 0;
}
}
// END MOD multi download
this is the old insert that needs to be replaced if upgrading from beta to ver 2.0 or above// MOD multi download
function multi_download_resize($file, $new_file, $quality, $resize_width, $resize_height) {
global $convert_options;
if (!function_exists(init_convert_options)) {
require(ROOT_PATH.'includes/image_utils.php');
}
$convert_options = init_convert_options();
$image_info = (defined("IN_CP")) ? getimagesize($file) : @getimagesize($file);
if (!$image_info) {
return false;
}
$scale = min($resize_width/$image_info[0], $resize_height/$image_info[1]);
$new_width = floor($scale*$image_info[0]);
$new_height = floor($scale*$image_info[1]);
$resize_handle = "resize_image_".$convert_options['convert_tool'];
if ($scale == '1'){
return $file;
}
elseif($resize_handle($file, $new_file, $quality, $new_width, $new_height, $image_info)) {
@chmod($new_file, CHMOD_FILES);
return true;
}
else {
return false;
}
}
// END MOD multi download
in the
lang\english\admin.php file
look for
?>
insert
before (updated insert for ver 2.0)//MOD multi downloads
$lang['multi_option'] = "Would you like to use multi-size download option for this category?";
$multi_download_optionlist = array(
"0" => "No",
"1" => "Yes, Allow all sizes to be selectable",
"2" => "Yes, Only allow smaller sizes then original to be selectable"
);
//END MOD multi downloads
original insert that needs to be replaced if upgrading from beta to ver 2.0//MOD Multi Downloads
$lang['multi_option'] = "Are you using multi download option for this category?"
//END MOD Multi Downloads
in the
lang\english\main.php file
look for
?>
insert
before (
updated insert for version 2.1) (updated for ver 4.0)// MOD multi download
$lang['download'] = "Download";
$lang['multi_select'] = "Select Size to Download";
$lang['original_size'] = "Original Size";
$lang['multi_resolution'] = "Your Screen Resolution is : ";
$lang['multi_down_group1'] = "4:3 Display";//create an entry for each one or your groups from the global.php file in this manor
$lang['multi_down_group2'] = "16:9 Display";
$lang['multi_down_group3'] = "16:10 Display";
$lang['multi_down_group4'] = "Mobile";
$lang['multi_down_group5'] = "Blackberry";
// END MOD multi download
in the
template\your template\details.html file
the fun part.
my file I had something like this...
{lightbox_button} {postcard_button} {download_button} {download_zip_button}
I
replaced this with
{lightbox_button} {postcard_button}{if not_multi_download} {download_button} {download_zip_button}
{endif not_multi_download}
<!-- Mod multi downloads -->
{if yes_multi_download}
{multi_download_options}
{endif yes_multi_download}
<!-- end mod-->
what you are trying to do is to remove the download and zip buttons if you are using the multi download and display the multi download option instead.
different templates may be setup differently.
(New to version 4.4)To create the template used for the popup window...
Create a file in your templates folder and call it "multi_popup.html"
Copy the following code into that file and save the file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="{direction}">
<head>
<title>{prepend_head_title}{site_name}</title>
<meta http-equiv="content-type" content="text/html; charset={charset}">
<meta name="description" content="{detail_meta_description}{site_name}">
<meta name="keywords" content="{detail_meta_keywords}">
</head>
<body>
<img src="{img_url}"></img>
</body>
</html>
and you should be ready to go.