• [MOD] Second Thumbnail Size 5 0 5 1
Currently:  

Author Topic: [MOD] Second Thumbnail Size  (Read 75724 times)

0 Members and 1 Guest are viewing this topic.

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
[MOD] Second Thumbnail Size
« on: June 10, 2009, 06:16:27 PM »
 :flag-de: - zunächst einmal nur in deutsch ...
 :flag-en: - a englisch version is coming soon ... or later ...  ;) ... meanwhile use this  English-Google-Translation ...

Vorbemerkung :
  • Mit dieser Modifikation ist es möglich überall in den Templates auf eine zweite Größe der Vorschaubilder zuzugreifen.
  • Konkret wurde diese Möglichkeit durch Rantanplan1966 hier http://www.4homepages.de/forum/index.php?topic=25013.0 angefragt. Dort sind auch Bilder zu dieser Problemstellung zu finden.
  • Um z.B. im Standard-Template in der linken Navigationsspalte, die eine Breite von 150px hat, auch Thumbnails als Zufallsbild zu zeigen, die von der Webstite-Einstellung her aber gößer als 150px sind, ohne dass dadurch das Template (speziell die Navigationsspalte) auseinandergezerrt und so das Template gesprengt wird.
  • Das Gleich gilt natürlich auch für andere Templates, bei denen dieses Problem auftritt.
  • Andererseits kann man das neue, kleine Thumbnail aber auch woanders, z.B. in der Top-List, verwenden.
  • Da ich dieses Problem schon auf diversen 4images-Websites gesehen habe, möchte hier mal etwas Hilfestellung geben, um es aus der Welt zu schaffen ... ;)

Installation :


1.Schritt :
finde in der /includes/functions.php im Abschnitt function get_thumbnail_code  folgende Codezeilen :

  
return $thumb;
}


und füge danach diese Codezeilen ein :

//--- Thumbnail small Code ---------------------------------------------------------
function get_thumbnail_small_code($media_file_name$thumb_file_name ""$image_id$cat_id$image_name ""$mode ""$show_link 1$open_window 0) {
  global 
$site_sess$config;
  
  
$max_width "80"// Hier maximale Breite der Thumbnails in Pixel eingeben !

  
if (!check_media_type($media_file_name)) {
    
$thumb "<img src=\"".ICON_PATH."/404.gif\" border=\"0\" alt=\"\" style=\"max-width: ".$max_width."px; width: expression(this.width > ".$max_width." ? ".$max_width.": true);\" />";
  }
  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);
      
$width_height = (!empty($image_info[3])) ? " ".$image_info[3] : "";
      
$thumb "<img src=\"".$file_src."\" border=\"0\"".$width_height." alt=\"".$image_name."\" style=\"max-width: ".$max_width."px; width: expression(this.width > ".$max_width." ? ".$max_width.": true);\" />";
    }
    else {
      
$file_src get_file_path($thumb_file_name"thumb"$cat_id01);
      
$image_info = @getimagesize($file_src);
      
$width_height = (!empty($image_info[3])) ? " ".$image_info[3] : "";
      
$thumb "<img src=\"".$file_src."\" border=\"".$config['image_border']."\"".$width_height." alt=\"".$image_name."\" style=\"max-width: ".$max_width."px; width: expression(this.width > ".$max_width." ? ".$max_width.": true);\" />";
    }
  }
  if (
$show_link) {
    if (
$open_window) {
      
$thumb "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id.((!empty($mode)) ? "&amp;mode=".$mode ""))."\" onclick=\"opendetailwindow()\" target=\"detailwindow\">".$thumb."</a>";
    }
    else {
      
$thumb "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id.((!empty($mode)) ? "&amp;mode=".$mode ""))."\">".$thumb."</a>";
    }
  }
  return 
$thumb;
}
//--- Thumbnail small Code ---------------------------------------------------------


Zur Konfiguration stellst du unter $max_width  am Anfang dieser Codepassade deine gewünschte, zweite, neue, maximale Thumbnailbreite in Pixel ein !


2.Schritt :
finde in der /includes/functions.php im Abschnitt function show_image  folgende Codezeilen :

"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),


und füge danach diese Codezeilen ein :

"thumbnail_small" => get_thumbnail_small_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),



3. Schritt :
Nun kannst du überall in den Templates die neue, zweite, kleine Thumbnailgröße zusätzlich verwenden ...
...statt :
Code: [Select]

{thumbnail}


... ist jetzt dafür zu verwenden :
Code: [Select]

{thumbnail_small}


In dem konkret angefragten Fall ging es um das Thumbnail-Zufallsbild in der linken Navigationsspalte. Dazu ist die Änderung {thumbnail} -> {thumbnail_small}  in der /templates/<dein_template>/random_image.html vorzunehmen.


Anmerkungen :
  • Mit dieser Modifikation werden keine neuen Thumbnails / Thumbnailgrößen erzeugt und / oder gespeichert.
  • Die neue Größe der Thumbnails resultiert aus einer Scallierung der vorhandenen Thumbnails.
  • Sämtliche Funktionen, die zum "Standard-Thumbnail" gehören (Rechte, Verlinkung u.d.gl.) sind auch beim "Small-Thumbnail" zu finden.

In der Hoffnung nirgends mehr gesprengte Navigationsleisten zu sehen ...
mawenzi
« Last Edit: May 12, 2012, 01:09:59 PM by mawenzi »
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline rustynet

  • Addicted member
  • ******
  • Posts: 1.031
  • {if msg}{msg}{endif msg}
    • View Profile
    • rustynet.de
Re: [MOD] Second Thumbnail Size
« Reply #1 on: June 11, 2009, 09:40:34 PM »
Ich habe eine alternative Lösung.

Einfach die Datei random_image.html gegen die neue (siehe Anhang) austauschen

Die Werte
Code: [Select]
width="120" height="90" kann man mit Editor (notepad etc.) beliebig ändern

Dasselbe gilt dann auch für random_cat_image.html

Viel Glück!
« Last Edit: June 11, 2009, 10:43:03 PM by rustynet »

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [MOD] Second Thumbnail Size
« Reply #2 on: June 11, 2009, 11:11:08 PM »
@rusty

... hat aber den Nachteil der fixen Seitenabmessungen für das Thumbnail ...
... und kann auch nur dort verwendet werden ... nicht z.B auch in einer zweiten  thumbnail_bit.html ... oder bei sonstiger Thumb-Verwendung ...
... wenn das kleine Thumbnail (fix) nur in der random_image.html werden soll ... dann ist es ok ...
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline rustynet

  • Addicted member
  • ******
  • Posts: 1.031
  • {if msg}{msg}{endif msg}
    • View Profile
    • rustynet.de
Re: [MOD] Second Thumbnail Size
« Reply #3 on: June 12, 2009, 08:22:18 AM »
ah so, ja da hast Du natürlich recht

ich dachte, es handelte sich nur um das Zufallsbild:
http://www.4homepages.de/forum/index.php?topic=25013

Offline Rantanplan1966

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: [MOD] Second Thumbnail Size
« Reply #4 on: July 01, 2009, 08:18:11 AM »
Der Mod von Mawenzi funktioniert mit... allerdings mit einer kleinen Ausnahme!

Die Spalte schiebt sich nun zwar nicht mehr auf... allerdings werden die Thumbnails im Querformat leicht verzerrt dargestellt.

Auf meiner Seite http://www.matthiasbenkel.de/gallery-online/index.php habe ich normalerweise eine Thumbnailgröße von 170.
Durch den Mod von Mawenzi werden nun die Zufallsbilder im Querformat auf eine Breite von 150 reduziert... die Höhe der Thumbnails bleibt aber weiterhin bestehen.
Zufallsbilder im Hochformat werden richtig dargestellt, da die längste Seite (Höhe) 170 hat und die Breite dieser Thumbnails sowieso kleiner als 150 ist.

Kann mir jemand einen Tip geben wie das Seitenverhältnis der Zufallsbilder im Querformat (thumbnails_smal) beibehalten wird, sodaß keine Verzerrung erfolgt?

Vielen Dank und Gruss,
Matthiasl 

Rembrandt

  • Guest
Re: [MOD] Second Thumbnail Size
« Reply #5 on: July 15, 2009, 07:31:33 AM »
Hi!

ich hätte da einen vorschlag,vielleicht möchte @mawenzi das in seinen script übernehmen.


function get_thumbnail_small_code($media_file_name$thumb_file_name ""$image_id$cat_id$image_name ""$mode ""$show_link 1$open_window 0) {
  global 
$site_sess$config$site_template;
  
//####### Config ###############################  
  
$maxwidth "80"// pixel
//####### Config ############################### 

  
if (!check_media_type($media_file_name)) {
    
$thumb "<img src=\"".ICON_PATH."/404.gif\" border=\"0\" alt=\"\" >";
  }
  else {
    if (!
get_file_path($media_file_name"media"$cat_id00)) {
      
$file_src ICON_PATH."/".get_file_extension($media_file_name).".gif";
      
$image_info = @getimagesize($file_src);
       
$thumb_width $image_info[0]."px";
       
$thumb_height $image_info[1]."px";
       
$thumb "<img src=\"".$file_src."\" style=\"border:0px;width:$thumb_width; height:$thumb_height;\" alt=\"".format_text($image_name2)."\" >";
    }
    else {
      
$file_src get_file_path($media_file_name"media"$cat_id01);
      
$image_info = @getimagesize($file_src);
      
$thumb_width $image_info[0];
      
$thumb_height $image_info[1];
      
      if (
$thumb_width $maxwidth){ 
        
$imageprop=$maxwidth/$thumb_width;
        
$imagevsize$thumb_height*$imageprop
        
$thumb_width=$maxwidth."px"
        
$thumb_heightround($imagevsize)."px";
      } 
      else{
        
$thumb_width $image_info[0]."px";
        
$thumb_height round($image_info[1])."px";
      }
      
      
$thumb "<img src=\"".$file_src."\" style=\"border:".$config['image_border']."px solid;width:$thumb_width; height:$thumb_height;\" alt=\"".format_text($image_name2)."\">";
    }
  }

  if (
$show_link) {
    if (
$open_window) {
      
$thumb "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id.((!empty($mode)) ? "&amp;mode=".$mode ""))." #z1\" onclick=\"opendetailwindow()\" target=\"detailwindow\">".$thumb."</a>";
    }
    else {
      
$thumb "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id.((!empty($mode)) ? "&amp;mode=".$mode ""))." #z1\">".$thumb."</a>";
    }
  }
  return 
$thumb;
}


mit $max = 80; wird die Weite angegeben, und das Seitenverhältniss bleibt immer gleich.

mfg Andi
« Last Edit: May 31, 2012, 05:13:25 PM by Rembrandt »

Offline lapas

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: [MOD] Second Thumbnail Size
« Reply #6 on: August 07, 2009, 04:57:51 PM »
It is real width this MOD make for every image big thumb (500x380px)?

I have small thumb but i want small and big thumb for every image.

Offline ghost_wizard

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: [MOD] Second Thumbnail Size
« Reply #7 on: February 24, 2010, 02:53:05 PM »
Hi!
Ich habe jetzt auch das Problem mit dem verzerrten Thumbnail!
Ich habe den MOD von Mawenzi getestet! Die Breite stimmt aber bei der Höhe stimmt es gar nicht! Das ganze ist verzerrt und falsch skaliert!
Soll ich jetzt den Code von Rembrand noch mit dazu schreiben?

Rembrandt

  • Guest
Re: [MOD] Second Thumbnail Size
« Reply #8 on: February 24, 2010, 05:12:08 PM »
...
Soll ich jetzt den Code von Rembrand noch mit dazu schreiben?
gegenfrage, warum nicht?

Offline ghost_wizard

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: [MOD] Second Thumbnail Size
« Reply #9 on: February 24, 2010, 05:32:59 PM »
ok, werde ich machen :D
Was mich verunsichert ist $max = 0.7; wo schreibe ich das rein?

Rembrandt

  • Guest
Re: [MOD] Second Thumbnail Size
« Reply #10 on: February 24, 2010, 06:01:17 PM »
anstatt
Code: [Select]
$max_width = "80";

Offline ghost_wizard

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: [MOD] Second Thumbnail Size
« Reply #11 on: February 24, 2010, 06:35:32 PM »
Alles klar!
Danke Dir :)

Offline haider512

  • Full Member
  • ***
  • Posts: 153
    • View Profile
Re: [MOD] Second Thumbnail Size
« Reply #12 on: February 28, 2011, 03:22:04 PM »
its a very nice mod..
but but i want some thing little different.. please will you help me that how should i make width of second one greater then original one.

i mean you proposed a way to make width smaller.

but my thumbnails are already smaller.

so can you prupose a way to make the image size bigger then the normal thumbnail size i have defined.

it will be really great to have two thumbnails.

1. normal one which 4images already have.
2. second thumbnail (like you defined but it only make smaller) have custom size (can increase or decrease size)

so we can use

{thumbnail}
{thumbnail_big}

please tell its possible..

Rembrandt

  • Guest
Re: [MOD] Second Thumbnail Size
« Reply #13 on: February 28, 2011, 04:07:15 PM »
.....
i mean you proposed a way to make width smaller.
....
no you can set "$max" greater than 1
http://www.4homepages.de/forum/index.php?topic=25017.msg138624#msg138624
« Last Edit: February 28, 2011, 08:18:52 PM by Rembrandt »

Offline haider512

  • Full Member
  • ***
  • Posts: 153
    • View Profile
Re: [MOD] Second Thumbnail Size
« Reply #14 on: February 28, 2011, 07:36:10 PM »
no you can set "$max" greater than 1

http://www.4homepages.de/forum/index.php?topic=25017.msg138624#msg138624

sir sorry i did not get .. so your mod can also increase thumbnail size.. should i use your changes directly or i have to use your code after i use mawenzi code?

its kind of confusing which code to change and which code i should not change??