Fragen zu iMinimize

Du hast Probleme beim Einbau oder bei der Benutzung eines Mods? In diesem Forum bist du richtig.
Forumsregeln
phpBB 2.0 hat das Ende seiner Lebenszeit überschritten
phpBB 2.0 wird nicht mehr aktiv unterstützt. Insbesondere werden - auch bei Sicherheitslücken - keine Patches mehr bereitgestellt. Der Einsatz von phpBB 2.0 erfolgt daher auf eigene Gefahr. Wir empfehlen einen Umstieg auf phpBB 3.0, welches aktiv weiterentwickelt wird und für welches regelmäßig Updates zur Verfügung gestellt werden.
Antworten
regie 510
Mitglied
Beiträge: 142
Registriert: 08.11.2008 23:40
Wohnort: Freiburg i. Br.

Fragen zu iMinimize

Beitrag von regie 510 »

Hallo zusammen,

schon seit langem bin ich auf der Suche nach einem vernünftigen Image-Resizer, der vor allen Dingen Thumbnails erzeugt und nicht nur via JavaScript-Verkleinerung on the fly arbeitet. Bilder können meine User mit UploadPic hochladen. Dieses sollte ja laut dem Autor um eine Thumbnail-Funktion erweitert werden (dann wär's absolut perfekt), doch mit der Einführung von phpBB 3 wird in dieser Richtung m.E. nichts mehr geschehen. So stieß ich auf iMinimize, der im großen und ganzen das macht, was ich will. Doch ich habe mich zu früh gefreut:

Da einige User verschiedene Bilderupload-Seiten (PostImage/ImageShack etc.) verwenden, werden oft Thumbnails mit [ img ]http://...[ /img ] verlinkt. Leider überschreibt iMinimize dies und es ist nicht möglich, das Bild in voller Größe zu sehen.

Wahrscheinlich müßte man etwas irgendwo in den BB-Code-Dateien ändern, aber dazu reichen meine Kenntnisse leider nicht aus. Vielleicht weiß hier jemand eine Lösung, dafür wäre ich echt sehr dankbar. Ich hätte nie gedacht, daß es so schwierig ist einen Bildresizer mit Thumbnail-Generierung zu finden.

Hier ist der Code von iMinimize:

Code: Alles auswählen

######################################################## 
## MOD Title: iMinimize with Thumbnails Revised Edition
## MOD Author: Nome < nome@bk.ru > Modified by Andreas Nielsen
## MOD Version: 3.0
## 
## Installation Level: Easy 
## Installation Time: 4-5 Minutes 
## Files To Edit: 3
##			- templates/subSilver/bbcode.tpl
##			- language/lang_english/lang_main.php
##			- includes/bbcode.php
##			- posting.php
##
## iMinimize mod generates thumbnails for inpost images and displays them in the size you ##wish. It also have the ability to ensure that the image looks nice if you define only ##one of the two vars either height or width. You can also specify a image to be usen ##when its broken. Remember to chmod the images/thumbs directory to 0777.

This mod is not easy mod compitable. Please mail all support questions to LordThranduil@hotmail.com i will gladly try to answeer them.

Bug fixes in Revised Edition:
- Small images won't be stretched any more.
- Added error message when using .php images (will hopefully be supported in next edition)
- Fixed the error when editing posts
- Images are now quoteable
- Thanks to Mia_J (http://www-webmaster-debat.dk) for good feedback!
############################################################## 
## For Security Purposes, Please Check: http://www.phpbb.com/mods/downloads/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered 
## in our MOD-Database, located at: http://www.phpbb.com/mods/downloads/ 
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD! I would STRONGLY advice to uinstall all other versions of the mod before installing. 
# 
#-----[ COPY ]------------------------------------------ 
# 
preview.php to /
images/broken_link.gif to images/ 
templates/subSilver/preview_body.tpl to templates/subSilver/
images/thumbs to images/thumbs

##
## Note: You will have to make the following changes to all templates that your board supports
## I use 'subSilver' as an example
##
# 
#-----[ OPEN ]------------------------------------------ 
#

templates/subSilver/bbcode.tpl

# 
#-----[ FIND ]------------------------------------------ 
#

<!-- BEGIN img --><img src="{URL}" border="0" /><!-- END img -->

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

<!-- BEGIN img2 --><a href="preview.php?path={URL}" target="_blank" alt="{L_OPEN_IN_NEW_WINDOW}" title="{L_OPEN_IN_NEW_WINDOW}"><img src="{THUMBNAIL}" border="0" /></a><!-- END img2 -->

##
## Note: You will have to make the following changes to all languages that your board supports
## I use 'English' as an example
##

# 
#-----[ OPEN ]------------------------------------------ 
#

language/lang_english/lang_main.php

# 
#-----[ FIND ]------------------------------------------ 
#

//
// That's all Folks!
// -------------------------------------------------

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#

// iMinimize_MOD - start
$lang['No_Url'] = 'You haven't specified the picture';
$lang['no_php'] = 'iMinimize  doesn't support GD images... yet!';
$lang['In_New_Window'] = 'Open in new window';
// iMinimize_MOD - end

# 
#-----[ OPEN ]------------------------------------------ 
# 

includes/bbcode.php

# 
#-----[ FIND ]------------------------------------------ 
# 

	$bbcode_tpl['img'] = str_replace('{URL}', '\\1', $bbcode_tpl['img']);

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 

		$bbcode_tpl['img'] = str_replace('{URL}', '\\1\\3', $bbcode_tpl['img']);

	// iMinimize_MOD - start
	$bbcode_tpl['img2'] = str_replace('{THUMBNAIL}', '\\1', $bbcode_tpl['img2']);
	$bbcode_tpl['img2'] = str_replace('{URL}', '\\2', $bbcode_tpl['img2']);
	$bbcode_tpl['img2'] = str_replace('{L_RESIZED}',$lang['Resized'],$bbcode_tpl['img2']);
	$bbcode_tpl['img2'] = str_replace('{L_OPEN_IN_NEW_WINDOW}',$lang['In_New_Window'],$bbcode_tpl['img2']);
	// iMinimize_MOD - end

# 
#-----[ FIND ]------------------------------------------ 
# 
	return $bbcode_tpl;
}

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
// iMinimize_MOD - start
function getsize($url) {
	global $userdata;
	// Maximum width and height for inpost images
	$iWidth = 300;
	$iHeight = 0;

  	// JPEG Quality 
  	$quality = 85; 


	$base = basename($url);
	$base_ext = substr($base, 0, -4);
	$id = $userdata['username'] . "_" . $base_ext;

	// broken_link
	$broken_link = $phpbb_root_path . "images/broken_link.gif";
	if(@!$size = getimagesize($url)) {
	return $broken_link;
	}
	
	$img_size = getimagesize($url);
	$real_width = $img_size[0];
	$real_height = $img_size[1];

	if($real_width > $iWidth OR $real_height > $iHeight) {

	// Find the height or width if 0 is the value.
	if($iHeight == 0) {
	$percent = $size[1] / $size[0] * 100;
	$iHeight = round($iWidth / 100 * $percent, 0);
	}
	if($iWidth == 0) {
	$percent = $size[0] / $size[1] * 100;
	$iWidth = round($iHeight / 100 * $percent, 0);
	}

	// Look up the extension of the image and use the right functions.
	$cut_url = strlen($url) - 3;
	$ext = substr($url, $cut_url);

	// .jpg
	if($ext == "jpg") {
	$im = imagecreatefromjpeg($url); 
  	$ow = imagesx( $im ); 
  	$oh = imagesy( $im ); 
  	$wscale = $iWidth / $ow; 
  	$hscale = $iHeight / $oh; 
  	$scale = ( $hscale < $wscale ? $hscale : $wscale ); 
  	$nw = round( $ow * $scale, 0 ); 
  	$nh = round( $oh * $scale, 0 ); 
  	$dstim = imagecreatetruecolor( $nw, $nh ); 
  	imagecopyresampled( $dstim, $im, 0, 0, 0, 0, $nw ,$nh ,$ow ,$oh ); 
  	imagejpeg( $dstim, $phpbb_root_path . "images/thumbs/" . $id . ".jpg", $quality); 
  	imagedestroy( $dstim ); 
	$thumb = $id . ".jpg";

	// .gif
	} elseif($ext == "gif") {
	$im = imagecreatefromgif($url); 
  	$ow = imagesx( $im ); 
  	$oh = imagesy( $im ); 
  	$wscale = $iWidth / $ow; 
  	$hscale = $iHeight / $oh; 
  	$scale = ( $hscale < $wscale ? $hscale : $wscale ); 
  	$nw = round( $ow * $scale, 0 ); 
  	$nh = round( $oh * $scale, 0 ); 
  	$dstim = imagecreatetruecolor( $nw, $nh ); 
  	imagecopyresampled( $dstim, $im, 0, 0, 0, 0, $nw ,$nh ,$ow ,$oh ); 
  	imagejpeg( $dstim, $phpbb_root_path . "images/thumbs/" . $id . ".gif"); 
  	imagedestroy( $dstim ); 
	$thumb = $id . ".gif";

	// .png
	} elseif($ext == "png") {
	$im = imagecreatefrompng($url); 
  	$ow = imagesx( $im ); 
  	$oh = imagesy( $im ); 
  	$wscale = $iWidth / $ow; 
  	$hscale = $iHeight / $oh; 
  	$scale = ( $hscale < $wscale ? $hscale : $wscale ); 
  	$nw = round( $ow * $scale, 0 ); 
  	$nh = round( $oh * $scale, 0 ); 
  	$dstim = imagecreatetruecolor( $nw, $nh ); 
  	imagecopyresampled( $dstim, $im, 0, 0, 0, 0, $nw ,$nh ,$ow ,$oh ); 
  	imagepng( $dstim, $phpbb_root_path . "images/thumbs/" . $id . ".png"); 
  	imagedestroy( $dstim ); 
	$thumb = $id . ".png";
	
	// Hvis det skulle være .php endelser!
	} elseif($ext == "php") {
	$iUrl = $lang['no_php'];
	return $iUrl;
	
	// Ellers kan billedet ikke virke!
	} else {
	return $broken_link;
	}
	}
		

			$iUrl = "[" . $phpbb_root_path . "images/thumbs/" . $thumb . "]" . $url;
	// Hvis billedet nu ikke er for stort!
	if($real_width < $iWidth && $real_height < $iHeight) {
			$iUrl = "[" . $url . "]" . $url;
	}
		return $iUrl;
}
// iMinimize_MOD - end

# 
#-----[ FIND ]------------------------------------------ 
#
	// Patterns and replacements for URL and email tags..
	$patterns = array();
	$replacements = array();

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
	// iMinimize_MOD - start
	$patterns[] = "#\[img:$uid\]\[(.*?)\](.*?)\[/img:$uid\]#si";
	$replacements[] = $bbcode_tpl['img2'];
	// iMinimize_MOD - end

# 
#-----[ FIND ]------------------------------------------ 
#
	// [img]image_url_here[/img] code..
	$text = preg_replace("#\[img\]((ht|f)tp://)([^ \?&=\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]#sie", "'[img:$uid]\\1' . str_replace(' ', '%20', '\\3') . '[/img:$uid]'", $text);

# 
#-----[ REPLACE WITH ]------------------------------------------ 
#
	// iMinimize_MOD - start
	$text = preg_replace("#\[img\]\[(([^ \?&=\"\n\r\t<]*?(\.(jpg|jpeg|gif|png))))\]((ht|f)tp://)([^ \?&=\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]#sie", "'[img:$uid][\\2]\\2' . str_replace(' ', '%20', '\\5') . '[/img:$uid]'", $text);
	// iMinimize_MOD - end

	// [img]image_url_here[/img] code..
	$text = preg_replace("#\[img\]((ht|f)tp://)([^ \?&=\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]#sie", "'[img:$uid]' . getsize('\\1'.str_replace(' ', '%20', '\\3')) . '[/img:$uid]'", $text);

#
#-----[ OPEN ]----------------------------------------------------------
#
posting.php

#
#-----[ FIND ]----------------------------------------------------------
#

		if ( $post_info['bbcode_uid'] != '' )
		{
			$message = preg_replace('/\:(([a-z0-9]:)?)' . $post_info['bbcode_uid'] . '/s', '', $message);
		}

		$message = str_replace('<', '<', $message);
		$message = str_replace('>', '>', $message);
		$message = str_replace('<br />', "\n", $message);
#
#---[ AFTER ADD ]-------------------------------------------------------
#
		
// iMinimize MOD -start
		// Find a picture that belongs to the author and then take the [] out of the message
		$handle = opendir($phpbb_root_path . "images/thumbs/");
		$posting_user = $post_info['username'];
		if($posting_user == "") {
		$posting_user = "Anonymous";
		} 
		while (false !== ($thumb = readdir($handle))) { 
      		 	$message = str_replace("[images/thumbs/" . $thumb . "]", "", $message);
	   }
	   // iMinimize MOD -stop

# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM

Gruß, Norbert
regie 510
Mitglied
Beiträge: 142
Registriert: 08.11.2008 23:40
Wohnort: Freiburg i. Br.

Re: Fragen zu iMinimize

Beitrag von regie 510 »

Hallo,

anscheinend weiß niemand eine Lösung? Zu Zeit erzeuge ich die Thumbnails von Hand mit IrfanView, lade diese in ein Verzeichnis "thumbs" auf den Server hoch, editiere das Posting nach und verlinke via [url=http://www.fremdlink.de/gross.jpg][img]http://www.meinforum.de/thumbs/klein.jpg[/img][/url]. Dann wird bei Klick auf das Thumb ein neues Browserfenster mit dem Bild in Originalgröße geöffnet.

Eine sehr umständliche Geschichte, wenn man das bei mehreren Bildern machen muß. Es wäre echt eine tolle Sache, wenn man das mit einem Script automatisieren könnte. iMinimize ist ein sehr guter Ansatz, nur sollten eben Links zu PostImage, Imageshack etc. nicht beeinflußt werden.
Gruß, Norbert
Antworten

Zurück zu „phpBB 2.0: Mod Support“