Frage zu Bilder automatisch verkleinern MOD
Verfasst: 06.08.2007 20:54
Hi
Ich habe versucht 2 Mods einzubauen
den ( [img] autoresize MOD ) der in Beiträgen Bilder automatisch verkleinert und dazu den ( Limit Image Width MOD ) der das gleiche für die Sig Bilder macht, es funktioniert aber nur entweder oder und zwar immer der zuerst kommende Code.
Kann man die Beiden irgendwie miteinander kombinieren ??
Hier mal die Codes der beiden Mods
Ich würde mich über Hilfe sehr freuen !
freundlicher Gruß
Red Benz
Ich habe versucht 2 Mods einzubauen
den ( [img] autoresize MOD ) der in Beiträgen Bilder automatisch verkleinert und dazu den ( Limit Image Width MOD ) der das gleiche für die Sig Bilder macht, es funktioniert aber nur entweder oder und zwar immer der zuerst kommende Code.
Kann man die Beiden irgendwie miteinander kombinieren ??
Hier mal die Codes der beiden Mods
Code: Alles auswählen
##############################################################
## MOD Title: Limit Image Width MOD
## MOD Author: Vic D'Elfant < vic@pythago.nl > (Vic D'Elfant) ##############################################################
#
#-----[ OPEN ]------------------------------------------
#
includes/bbcode.php
#
#-----[ FIND ]------------------------------------------
#
// [img]image_url_here[/img] code..
// This one gets first-passed..
$patterns[] = "#\[img:$uid\](.*?)\[/img:$uid\]#si";
$replacements[] = $bbcode_tpl['img'];
#
#-----[ REPLACE WITH ]------------------------------------------
#
// [img]image_url_here[/img] code..
// This one gets first-passed..
//$patterns[] = "#\[img:$uid\](.*?)\[/img:$uid\]#si";
//$replacements[] = $bbcode_tpl['img'];
#
#-----[ FIND ]------------------------------------------
#
// [email]user@domain.tld[/email] code..
$patterns[] = "#\[email\]([a-z0-9&\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/email\]#si";
$replacements[] = $bbcode_tpl['email'];
#
#-----[ AFTER, ADD ]------------------------------------------
#
//
// Limit Image Width MOD --- BEGIN
//
global $board_config;
$max_image_width = intval($board_config['max_img_width']);
if ( preg_match_all("#\[img:$uid\](.*?)\[/img:$uid\]#si", $text, $images) )
{
$image_patterns = array();
$image_replacements = array();
while ( list($index, $image_source) = each($images[1]) )
{
if ( intval($max_image_width) != 0 )
{
list($image_width, $image_height) = @getimagesize($image_source);
if ( $image_width && $image_width > $max_image_width )
{
$image_patterns[] = $images[0][$index];
$image_replacements[] = '<a href="#" onClick="javascript:window.open(\'' . $images[1][$index] . '\',\'limit_image_mod_popup_img' . $index . '\',\'height=' . $image_height . ',width=' . $image_width . ',status=yes,toolbar=no,menubar=no,location=no,resizable=yes\');"><img src="' . $images[1][$index] .'" width="' . $max_image_width . '" alt="' . $lang['LIW_click_image'] . '" border="0"></a><br /><span class="gensmall">' . $lang['LIW_click_image_explain'] . '</span>';
}
else
{
$image_patterns[] = $images[0][$index];
$image_replacements[] = '<img src="' . $images[1][$index] . '" alt="" border="0">';
}
}
else
{
$image_patterns[] = $images[0][$index];
$image_replacements[] = '<img src="' . $images[1][$index] . '" alt="" border="0">';
}
}
$text = str_replace($image_patterns, $image_replacements, $text);
}
//
// Limit Image Width MOD --- END
//
#
#-----[ OPEN ]------------------------------------------
#
admin/admin_board.php
#
#-----[ FIND ]------------------------------------------
#
"L_MAX_SIG_LENGTH_EXPLAIN" => $lang['Max_sig_length_explain'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
"L_MAX_IMG_WIDTH" => $lang['Max_img_width'],
"L_MAX_IMG_WIDTH_EXPLAIN" => $lang['Max_img_width_explain'],
#
#-----[ FIND ]------------------------------------------
#
"SIG_SIZE" => $new['max_sig_chars'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
"MAX_IMG_WIDTH" => $new['max_img_width'],
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/admin/board_config_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<tr>
<td class="row1">{L_MAX_SIG_LENGTH}<br /><span class="gensmall">{L_MAX_SIG_LENGTH_EXPLAIN}</span></td>
<td class="row2"><input class="post" type="text" size="5" maxlength="4" name="max_sig_chars" value="{SIG_SIZE}" /></td>
</tr>
#
#-----[ AFTER, ADD ]------------------------------------------
#
<tr>
<td class="row1">{L_MAX_IMG_WIDTH}<br /><span class="gensmall">{L_MAX_IMG_WIDTH_EXPLAIN}</span></td>
<td class="row2"><input class="post" type="text" size="5" maxlength="4" name="max_img_width" value="{MAX_IMG_WIDTH}" /></td>
</tr>
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_admin.php
#
#-----[ FIND ]------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$lang['Max_img_width'] = 'Maximum image width';
$lang['Max_img_width_explain'] = 'Specify the maximum width of an image posted using the [img] tags here. The value should be in pixels.<br>Entering 0 will disable the Limit Image Width MOD';
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$lang['LIW_click_image'] = 'Click to view this image at its original size';
$lang['LIW_click_image_explain'] = 'Click on the image to view it at its original size';
#
#-----[ SQL ]------------------------------------------
#
INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_img_width', '500');
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
Code: Alles auswählen
##############################################################
## MOD Title: [img] autoresize MOD
## MOD Author: MagMo < N/A > (N/A) http://phpbb.mwegner.de/
##############################################################
#
#-----[ OPEN ]------------------------------------------------
#
includes/bbcode.php
#
#-----[ FIND ]------------------------------------------------
#
// [img]image_url_here[/img] code..
// This one gets first-passed..
#
#-----[ BEFORE, ADD ]------------------------------------------------
#
/* [img] autoresize Mod - Start
#
#-----[ FIND ]------------------------------------------------
#
$replacements[] = $bbcode_tpl['img'];
#
#-----[ AFTER, ADD ]------------------------------------------------
#
[img] autoresize Mod - End */
#
#-----[ FIND ]------------------------------------------------
#
// Remove our padding from the string..
$text = substr($text, 1);
#
#-----[ BEFORE, ADD ]------------------------------------------------
#
// [img] autoresize Mod - Start
// Maximale Bildbreite, bei $ImageMaxWidth = 0 wird die Breite nicht ueberprueft
$ImageMaxWidth = 0;
// Maximale Bildhoehe, bei $ImageMaxHeight = 0 wird die Hoehe nicht ueberprueft
$ImageMaxHeight = 0;
$textIMG_a = array();
$textIMG_a = preg_split("#\[img:$uid\]#is", $text);
if ((is_array($textIMG_a)) && (count($textIMG_a) > 0))
{
unset($textIMG_e);
unset($i);
$textIMG_c = count($textIMG_a);
$textIMG_e = array();
for ($i=0; $i<$textIMG_c; $i++)
{
if ((($i == 0) && (substr($textIMG_a[0],0,1) != ' ')) || ($i > 0))
{
$textIMG_e[] = preg_replace("#\[/img:$uid\].*#is", '', $textIMG_a[$i]);
}
}
if ((isset($textIMG_e)) && (is_array($textIMG_e)))
{
unset($i);
$textIMG_s = $text;
$textIMG_c = count($textIMG_e);
for ($i=0; $i<$textIMG_c; $i++)
{
$textIMG_e[$i] = eregi_replace('\[','\[',$textIMG_e[$i]);
unset($ImageInfo);
$ImageInfo = @ getimagesize($textIMG_e[$i]);
if ((!isset($ImageInfo)) || (is_null($ImageInfo)) || (!is_array($ImageInfo)) || (($ImageInfo[2] != 1) && ($ImageInfo[2] != 2) && ($ImageInfo[2] != 3)))
{
$textIMG_s = preg_replace("#\[img:$uid\]".$textIMG_e[$i]."\[/img:$uid\]#is", '<img src="'.$textIMG_e[$i].'" border="0" />', $textIMG_s);
}
else
{
unset($ImageWidth);
unset($ImageHeight);
unset($ImageFactor);
$ImageWidth = $ImageInfo[0];
$ImageHeight = $ImageInfo[1];
if (($ImageWidth > $ImageMaxWidth) && ($ImageMaxWidth > 0))
{
$ImageFactor = $ImageMaxWidth / $ImageWidth;
$ImageWidth = $ImageWidth * $ImageFactor;
$ImageHeight = $ImageHeight * $ImageFactor;
}
if ((floor($ImageHeight) > $ImageMaxHeight) && ($ImageMaxHeight > 0))
{
$ImageFactor = $ImageMaxHeight / $ImageHeight;
$ImageWidth = $ImageWidth * $ImageFactor;
$ImageHeight = $ImageHeight * $ImageFactor;
}
$ImageWidth = floor($ImageWidth);
$ImageHeight = floor($ImageHeight);
$textIMG_s = preg_replace("#\[img:$uid\]".$textIMG_e[$i]."\[/img:$uid\]#is", '<a href="'.$textIMG_e[$i].'" title="' . $lang['IMG_autoresize_Mod'] . '" target="_blank"><img src="'.$textIMG_e[$i].'" width="' . $ImageWidth . '" height="' . $ImageHeight . '" border="0" alt="' . $lang['IMG_autoresize_Mod'] . '" /></a>', $textIMG_s);
}
}
$text = $textIMG_s;
}
}
// [img] autoresize Mod - End
#
#-----[ OPEN ]------------------------------------------------
#
language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]------------------------------------------------
#
// [img] autoresize Mod - Start
$lang['IMG_autoresize_Mod'] = 'Click here to view the image in full size.';
// [img] autoresize Mod - End
#
#-----[ OPEN ]------------------------------------------------
#
language/lang_german/lang_main.php
#
#-----[ FIND ]------------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]------------------------------------------------
#
// [img] autoresize Mod - Start
$lang['IMG_autoresize_Mod'] = 'Hier klicken, um das Bild in Originalgröße zu sehen.';
// [img] autoresize Mod - End
#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------------
#
# EoM
Ich würde mich über Hilfe sehr freuen !
freundlicher Gruß
Red Benz