4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: Rembrandt on August 20, 2012, 04:21:38 PM
-
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
-
Hi Andi,
Perfekt!!
Du bist der Beste!!!!!
Vielen Dank
paulchen
-
Hallo Andi,
nur zur Info.
Es funktioniert wieder.
Sorry für die Umstände.
Es war wohl ein Cache Problem bei 2 Rechnern….
Hab ich noch nie gehabt.
noch mal vielen Dank für die Mühe.
paulchen
-
NP, Hauptsache es funktioniert wieder...
mfg Andi
-
Great MOD!
But there is a problem when a member is uploading a zip file and not an image.
In this case the MOD doesn't change the uploaded thumbnail image and the worst, doesn't let the thumb appear (https://dl.dropbox.com/u/86453764/thumb.jpg)
Any solution for this case please :oops:
-
Hi!
Thank you for the hint!
test it please:
search in the code:
if (!get_file_path($media_file_name, $orig_file, $cat_id, 0, 0)) {
and replace:
if (!get_file_path($media_file_name, "thumb", $cat_id, 0, 0)) {
and please give me a Feedback, thx.
mfg Andi
-
Hi Andi,
After the change you suggested I get this (https://dl.dropbox.com/u/86453764/zip%20thumb.jpg) instead of the real preview...
Of course it is better, but doesn't fix the preview problem...
-
I have already noticed....
I am looking for a solution....
mfg Andi
-
wow! Thanks, you are so kind and helpful!
-
so.. I have updated step 1.) in my first post.
For me works it, i hope for you too. :)
mfg Andi
-
It works great! Thank you so much! :D
-
np... :)
mfg Andi
-
First of all, thank you for this mod. It works fine with 1.7.11 and I love it.
I have only one question regarding the top lists. Normally I call an image preview/thumbnail on my toplist like this:
{image_downloads_thumb_xx}
After installing the mod there is no longer a thumbnail but a link. How do I manage it, that the small thumbnail is shown on toplist? I tried it like this:
{image_downloads_thumb_small_1} or {image_downloads_thumbnail_small_1}
but this doesn´t work. Do you have any idea how it can work, or does it need further changes in the code to show thumbnails on toplists after installing the mod?
vg Tiburon
-
post your top.php...
-
Hi Rembrandt,
thanks for answering. It was my mistake. After upgrading to 1.7.11 I forgot to change the original top.php file with my modified one. :oops: Your mod also works perfectly with a modified toplist. Sorry if I caused any inconvenience.
Tiburon
-
Hi,
I have a question regarding the mod. I tested a few things and as far as I can see the additional thumbnail sizes are all created from the original file but not from the thumbnail file. Is this correct?
Is there be a possibility to create additional thumbnail sizes from thumnbail file, if this file is big enough e.g. 600x450 px?
Thanks
Tiburon
-
in "ACP/General/Upload settings", set the Value higher:
Max. width of thumbnail in pixel
Max. heigth of thumbnail in pixel
for the function these values are relevant , not the real thumbnail size.
mfg Andi
-
Ah, thank you, I´ll try this. :)
-
In the thumbnail bit template, i changed {thumbnail} to {thumbnail_large} but the thumbnails are still showing the old size :(
-
thank my thumbnail problem solved :lol: :lol: 8)