Author Topic: [Mod] Different Thumbnail sizes  (Read 28609 times)

0 Members and 1 Guest are viewing this topic.

Rembrandt

  • Guest
[Mod] Different Thumbnail sizes
« 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_id00)) {
      
$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_name2)."\" >";
    }
    else {
      
$file_src get_file_path($media_file_name$orig_file$cat_id01);
      
$orig_file = (check_thumb_type($file_src)) ?  $orig_file "thumb";

      
$file_src get_file_path($thumb_file_name$orig_file$cat_id01);
      
$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_name2)."\">";    
    }
  }
  if (
$show_link) {
    if (
$open_window) {
      
$new_image "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id.((!empty($mode)) ? "&amp;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)) ? "&amp;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,050,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,0110,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,0200,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,0400,400), // The last two values are "width, height"
    //e.t.c.


mfg Andi
« Last Edit: September 18, 2012, 07:56:01 AM by Rembrandt »

Offline paule

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: [Mod] Different Thumbnail sizes
« Reply #1 on: August 20, 2012, 05:17:26 PM »
Hi Andi,

Perfekt!!
Du bist der Beste!!!!!

Vielen Dank

paulchen

Offline paule

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: [Mod] Different Thumbnail sizes
« Reply #2 on: September 02, 2012, 05:20:35 PM »
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

Rembrandt

  • Guest
Re: [Mod] Different Thumbnail sizes
« Reply #3 on: September 02, 2012, 05:27:22 PM »
NP, Hauptsache es funktioniert wieder...

mfg Andi

Offline niad

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Re: [Mod] Different Thumbnail sizes
« Reply #4 on: September 17, 2012, 06:09:15 PM »
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

Any solution for this case please  :oops:
I love 4images, it is really great work!

Rembrandt

  • Guest
Re: [Mod] Different Thumbnail sizes
« Reply #5 on: September 17, 2012, 06:47:34 PM »
Hi!

Thank you for the hint!

test it please:
search in the code:

if (!get_file_path($media_file_name$orig_file$cat_id00)) {

and replace:

if (!get_file_path($media_file_name"thumb"$cat_id00)) {


and please give me a Feedback, thx.

mfg Andi

Offline niad

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Re: [Mod] Different Thumbnail sizes
« Reply #6 on: September 17, 2012, 07:37:40 PM »
Hi Andi,
After the change you suggested I get this instead of the real preview...
Of course it is better, but doesn't fix the preview problem...
 
I love 4images, it is really great work!

Rembrandt

  • Guest
Re: [Mod] Different Thumbnail sizes
« Reply #7 on: September 17, 2012, 07:40:44 PM »
I have already noticed....
I am looking for a solution....

mfg Andi

Offline niad

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Re: [Mod] Different Thumbnail sizes
« Reply #8 on: September 17, 2012, 07:46:13 PM »
wow! Thanks, you are so kind and helpful!
I love 4images, it is really great work!

Rembrandt

  • Guest
Re: [Mod] Different Thumbnail sizes
« Reply #9 on: September 18, 2012, 07:59:20 AM »
so.. I have updated step 1.) in my first post.
For me works it, i hope for you too. :)

mfg Andi

Offline niad

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Re: [Mod] Different Thumbnail sizes
« Reply #10 on: September 18, 2012, 12:21:12 PM »
It works great! Thank you so much!  :D
I love 4images, it is really great work!

Rembrandt

  • Guest
Re: [Mod] Different Thumbnail sizes
« Reply #11 on: September 18, 2012, 12:59:21 PM »
np... :)

mfg Andi

Offline Tiburon

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
    • http://www.hintergrundbilder.de
Re: [Mod] Different Thumbnail sizes
« Reply #12 on: September 19, 2012, 09:05:34 AM »
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
----------------------------------

Have a nice Day

Rembrandt

  • Guest
Re: [Mod] Different Thumbnail sizes
« Reply #13 on: September 19, 2012, 05:51:10 PM »
post your top.php...

Offline Tiburon

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
    • http://www.hintergrundbilder.de
Re: [Mod] Different Thumbnail sizes
« Reply #14 on: September 20, 2012, 10:11:13 AM »
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
----------------------------------

Have a nice Day

 

Post your comments here