##############################################
## MOD Title: Large Images MOD
## MOD Author: Sian < [email]sebastian.weglarczyk@interia.pl[/email] >
## MOD Description: This MOD will allow the board administrators
## to set maximum width of an posted images.
## If width of an image exceeds entered value,
## a horizontal scrollbar will appear under image.
## This will maintain forum layout.
## Entering zero or leaving empty disables this function.
## MOD Version: 1.0
## Compatibility: 2.0.4 - 2.0.6 (prior release not tested but expected to work fine)
##
## Installation Level: Easy
## Installation Time: 5-10 Minutes
## Files To Edit: 5
## admin/admin_board.php
## includes/bbcode.php
## language/lang_english/lang_admin.php
## templates/subSilver/viewtopic_body.tpl
## templates/subSilver/admin/board_config_body.tpl
##
##############################################
## Security Disclaimer: This MOD Cannot Be Posted To Or Added At Any Non-Official phpBB Sites
##############################################
##
## Author Notes:
##
## To set maximum image width:
## Go to administration panel -> General Admin -> Configuration -> User and Forum Basic Settings
##
## This mod should work with any template, although there will be differences in the .tpl
## files with some templates. You should be able to work around the differences.
##
## If you have other templates or languages installed you should modify respective files.
##
##############################################
##
## MOD History:
##
## 2003-08-27 - Version 1.0
## - Initial final release
##
##############################################
## This MOD is released under the GPL License.
##############################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################
#
#
#-----[ SQL ]-------------------------------------------------
#
# Add the "image_max_width" value to the "config" table.
# You can use the following SQL statement, replacing
# the database name and the prefix with those of your choice.
#
INSERT INTO `phpbb_config` (`config_name`, `config_value`) VALUES ('image_max_width', '0');
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_board.php
#
#-----[ FIND ]------------------------------------------------
#
"L_MAX_SIG_LENGTH" => $lang['Max_sig_length'],
"L_MAX_SIG_LENGTH_EXPLAIN" => $lang['Max_sig_length_explain'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
// Start add - LargeImages MOD
"L_MAX_IMG_WIDTH" => $lang['Max_image_width'],
"L_MAX_IMG_WIDTH_EXPLAIN" => $lang['Max_image_width_explain'],
// End add - LargeImages MOD
#
#-----[ FIND ]------------------------------------------------
#
"SIG_YES" => $sig_yes,
"SIG_NO" => $sig_no,
"SIG_SIZE" => $new['max_sig_chars'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
// Start add - LargeImages MOD
"MAX_IMG_WIDTH" => $new['image_max_width'],
// End add - LargeImages MOD
#
#-----[ OPEN ]------------------------------------------------
#
includes/bbcode.php
#
#-----[ FIND ]------------------------------------------------
#
global $lang, $bbcode_tpl;
#
#-----[ REPLACE WITH ]----------------------------------------
#
// Start replacement - LargeImages MOD
global $lang, $bbcode_tpl, $board_config;
// Start replacement - LargeImages MOD
#
#-----[ FIND ]------------------------------------------------
#
$text = preg_replace($patterns, $replacements, $text);
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
// Start add - LargeImages MOD
if (!empty($board_config['image_max_width']) && ($board_config['image_max_width'] > 0))
{
if (preg_match_all("#\[img:$uid\](.*?)\[/img:$uid\]#si", $text, $images)) {
$imagePatterns = $imageReplacements = array();
foreach($images[1] as $index=>$image_link)
{
$image_dimensions = @getimagesize($image_link);
if ($image_dimensions && $image_dimensions[0] > $board_config['image_max_width']) {
$div_height = $image_dimensions[1] + 20;
$imagePatterns[] = $images[0][$index];
$imageReplacements[] = '<div style="width:'.$board_config['image_max_width'].'px; height:'.$div_height.'px; overflow:auto;">'.$images[0][$index].'</div>';
}
}
$text = str_replace($imagePatterns,$imageReplacements,$text);
}
}
// End add - LargeImages MOD
#
#-----[ OPEN ]------------------------------------------------
#
language/lang_english/lang_admin.php
#
#-----[ FIND ]------------------------------------------------
#
$lang['Max_sig_length'] = 'Maximum signature length';
$lang['Max_sig_length_explain'] = 'Maximum number of characters in user signatures';
#
#-----[ AFTER, ADD ]------------------------------------------
#
// Start add - LargeImages MOD
$lang['Max_image_width'] = 'Maximum images width';
$lang['Max_image_width_explain'] = 'If width of an image exceeds this value, a horizontal scrollbar will appear under image. This will maintain forum layout. Enter zero or leave empty to disable this function.';
// End add - LargeImages MOD
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/viewtopic_body.tpl
#
#-----[ FIND ]------------------------------------------------
#
<td class="{postrow.ROW_CLASS}" width="100%" height="28" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><a href="{postrow.U_MINI_POST}"><img src="{postrow.MINI_POST_IMG}" width="12" height="9" alt="{postrow.L_MINI_POST_ALT}" title="{postrow.L_MINI_POST_ALT}" border="0" /></a><span class="postdetails">{L_POSTED}: {postrow.POST_DATE}<span class="gen">&</span>& &{L_POST_SUBJECT}: {postrow.POST_SUBJECT}</span></td>
<td valign="top" nowrap="nowrap">{postrow.QUOTE_IMG} {postrow.EDIT_IMG} {postrow.DELETE_IMG} {postrow.IP_IMG}</td>
</tr>
<tr>
<td colspan="2"><hr /></td>
</tr>
<tr>
<td colspan="2"><span class="postbody">{postrow.MESSAGE}{postrow.SIGNATURE}</span><span class="gensmall">{postrow.EDITED_MESSAGE}</span></td>
</tr>
</table></td>
#
#-----[ REPLACE WITH ]----------------------------------------
#
<!-- Start replacement - LargeImages MOD -->
<td class="{postrow.ROW_CLASS}" width="100%" height="28" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><a href="{postrow.U_MINI_POST}"><img src="{postrow.MINI_POST_IMG}" width="12" height="9" alt="{postrow.L_MINI_POST_ALT}" title="{postrow.L_MINI_POST_ALT}" border="0" /></a><span class="postdetails">{L_POSTED}: {postrow.POST_DATE}<span class="gen">&</span><br />{L_POST_SUBJECT}: {postrow.POST_SUBJECT}</span></td>
<td valign="top" nowrap="nowrap">{postrow.REPLY_IMG_MINI} {postrow.QUOTE_IMG} {postrow.EDIT_IMG} {postrow.DELETE_IMG} {postrow.IP_IMG}</td>
</tr>
</table></td>
</tr>
<tr>
<td><hr /></td>
</tr>
<tr>
<td><span class="postbody">{postrow.MESSAGE}{postrow.SIGNATURE}</span><span class="gensmall">{postrow.EDITED_MESSAGE}</span></td>
</tr>
</table></td>
<!-- End replacement - LargeImages MOD -->
#
#-----[ 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 ]------------------------------------------
#
<!-- Start add - LargeImages MOD -->
<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="image_max_width" value="{MAX_IMG_WIDTH}" /> px.</td>
</tr>
<!-- End add - LargeImages MOD -->
#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------------
#
# EoM