Hi!
- one function for all different Thumbnail sizes
- the new thumbnails can be smaller or larger than the original thumbnails.
- Side ratio is respected
1.) search in includes/functions.php:
function get_thumbnail_code($media_file_name, $thumb_file_name = "", $image_id, $cat_id, $image_name = "", $mode = "", $show_link = 1, $open_window = 0) {
insert above:
//########### Start [Mod] Different Thumbnail sizes ############################
function get_thumbnail_resizer($media_file_name, $thumb_file_name = "", $image_id, $cat_id, $image_name = "", $mode = "", $show_link = 1, $open_window = 0, $new_width = "", $new_height = "", $contest = 0) {
global $site_sess, $config, $site_template;
$new_width = $new_width ? $new_width : $config['max_thumb_width'];
$new_height = $new_height ? $new_height : $config['max_thumb_height'];
$orig_file = ($new_width>$config['max_thumb_width'] || $new_height>$config['max_thumb_height']) ? "media" : "thumb";
if (!check_media_type($media_file_name)) {
$new_image = "<img src=\"".ICON_PATH."/404.gif\" border=\"0\" alt=\"\" >";
}
else {
if (!get_file_path($thumb_file_name, "thumb", $cat_id, 0, 0)) {
$file_src = ICON_PATH."/".get_file_extension($media_file_name).".gif";
$image_info = @getimagesize($file_src);
$orig_width = $image_info[0];
$orig_height = $image_info[1];
$new_image = "<img src=\"".$file_src."\" style=\"border:0px;width:".$orig_width."px; height:".$orig_height."px;\" alt=\"".format_text($image_name, 2)."\" >";
}
else {
$file_src = get_file_path($media_file_name, $orig_file, $cat_id, 0, 1);
$orig_file = (check_thumb_type($file_src)) ? $orig_file : "thumb";
$file_src = get_file_path($thumb_file_name, $orig_file, $cat_id, 0, 1);
$image_info = @getimagesize($file_src);
$orig_width = $image_info[0];
$orig_height = $image_info[1];
if($new_width<$orig_width || $new_height<$orig_height){
$orig_ratio = $orig_width / $orig_height;
if ($new_width / $new_height > $orig_ratio){
$new_width = round($new_height * $orig_ratio);
}
else{
$new_height = round($new_width/$orig_ratio);
}
}
else{
$new_width = $orig_width;
$new_height = $orig_height;
}
$new_image = "<img src=\"".$file_src."\" style=\"border:".$config['image_border']."px solid; width:".$new_width."px; height:".$new_height."px;\" alt=\"".format_text($image_name, 2)."\">";
}
}
if ($show_link) {
if ($open_window) {
$new_image = "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id.((!empty($mode)) ? "&mode=".$mode : ""))."\" onclick=\"opendetailwindow()\" target=\"detailwindow\">".$new_image."</a>";
}
else {
$new_image = "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id.((!empty($mode)) ? "&mode=".$mode : ""))."\">".$new_image."</a>";
}
}
return $new_image;
}
//########### End [Mod] Different Thumbnail sizes ############################
2.) search in includes/functions.php:
"thumbnail" => get_thumbnail_code($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link),
insert below so many rows as you need, example:
"thumbnail_small" => get_thumbnail_resizer($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link,0, 50,50), // The last two values are "width, height"
"thumbnail_medium" => get_thumbnail_resizer($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link,0, 110,110), // The last two values are "width, height"
"thumbnail_large" => get_thumbnail_resizer($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link,0, 200,200), // The last two values are "width, height"
"thumbnail_big" => get_thumbnail_resizer($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link,0, 400,400), // The last two values are "width, height"
//e.t.c.
mfg Andi