Author |
Message |
FosgateElite
Regular


Joined: Mar 26, 2006
Posts: 63
|
Posted:
Mon Apr 27, 2009 10:45 am |
|
I found a forum mod a few years ago that would limit the pixel size of images posted to forums with bbcode. If the image was over the max, it would resize it and create a "thumbnail link" to the full size image.
I searched and searched for this today but I could no find it. Anyone know what im talking about? |
|
|
|
 |
jakec
Site Admin

Joined: Feb 06, 2006
Posts: 3048
Location: United Kingdom
|
Posted:
Mon Apr 27, 2009 11:20 am |
|
Doesn't the forum attachment mod that comes with RN do this? |
|
|
|
 |
FosgateElite

|
Posted:
Tue Apr 28, 2009 6:55 pm |
|
Oh does it? My install of RN a year ago didn't have this. I had to add it manually.
Does it do what i'm talking about by converting the inserted image to a thumbnail and link to the full size image on-the-fly? Or do you just attach the images to the post with a link to the file without getting the thumbnail? |
|
|
|
 |
jakec

|
Posted:
Wed Apr 29, 2009 12:15 am |
|
I personally don't use it, but that is my understanding, I could be wrong of course. Give it a test run and see.  |
Last edited by jakec on Wed Apr 29, 2009 6:27 am; edited 1 time in total |
|
|
 |
sockettf
Hangin' Around

Joined: Mar 13, 2009
Posts: 28
|
Posted:
Wed Apr 29, 2009 2:05 am |
|
I got working a Forum resize image mod on my sites. With this mod all de img tags are limited to the width x height specified in admin panel and show thumbnail with a link to the full size image.
Try this, is easy and works very fine: Only registered users can see links on this board! Get registered or login!
Install with care in RavenNuke some bbcode.php modificatións not match the "search" instructions, but you can compare and only add the required changes. |
|
|
|
 |
dad7732
RavenNuke(tm) Development Team

Joined: Mar 18, 2007
Posts: 1242
|
Posted:
Tue May 05, 2009 11:55 am |
|
The attachemt feature in "forums" will do this, but only for attached images using that feature.
Forums => Attachments => Management => Attachment Filesize Settings |
|
|
|
 |
FosgateElite

|
Posted:
Tue May 05, 2009 2:49 pm |
|
Yeah, I played with those settings a bunch but I think my theme is keeping it from working correctly. |
|
|
|
 |
FosgateElite

|
Posted:
Sat May 09, 2009 5:33 pm |
|
sockettf wrote: | I got working a Forum resize image mod on my sites. With this mod all de img tags are limited to the width x height specified in admin panel and show thumbnail with a link to the full size image.
Try this, is easy and works very fine: Only registered users can see links on this board! Get registered or login!
Install with care in RavenNuke some bbcode.php modificatións not match the "search" instructions, but you can compare and only add the required changes. |
I cant seem to get registered on that site. I never get an email. Ive pretty much given up on the attach_mod in phpbb2. Its just not working for me. |
|
|
|
 |
dad7732

|
Posted:
Sat May 09, 2009 5:48 pm |
|
Re: attach_mod
Make sure when you upgraded to RN 2.30.01 that you also ran rndb_upgrade.php located in the /INSTALLATION directory as this will install the new tables required for the attach function. |
|
|
|
 |
FosgateElite

|
Posted:
Sat May 09, 2009 7:55 pm |
|
This was a fresh install. Was that part of the fresh install steps? |
|
|
|
 |
dad7732

|
Posted:
Sat May 09, 2009 8:16 pm |
|
In the forum configuration under attachment, anything you click on should bring up the preferences page(s) with no errors. If no errors then the tables are installed ok. In the management screen, attachments should be "enabled".
In your RN root directory, temporaraily rename the .htaccess file to .htaccessBAK and see if the attachment functions ok.
Also, just what is the problem, any errors or the images don't resize with no indication as to why not, etc. |
|
|
|
 |
FosgateElite

|
Posted:
Sat May 09, 2009 10:21 pm |
|
Ill try the htaccess change.
I dont get any errors, images just never resize and link... |
|
|
|
 |
sockettf

|
Posted:
Sun May 10, 2009 2:11 am |
|
Quote: | I cant seem to get registered on that site. I never get an email. Ive pretty much given up on the attach_mod in phpbb2. Its just not working for me. |
Ok, You can get the file --> Only registered users can see links on this board! Get registered or login!
Also, you can view the mod working --> Only registered users can see links on this board! Get registered or login! |
|
|
|
 |
FosgateElite

|
Posted:
Sun May 10, 2009 8:48 pm |
|
Perfect. That looks just like the one I used in the past. Thanks a TON! |
|
|
|
 |
FosgateElite

|
Posted:
Wed May 20, 2009 7:33 pm |
|
Giving the attach mod a second chance.
I have changed themes and the attachments work correctly.
When images are attached (from the users computer) the image shows up as a thumbnail, and files show up like files like they are supposed to.
So now here is my question.
Is this mod "designed" to thumbnail images posted with bbcode where the image is hosted on another site like photobucket?
That was the main reason I wanted to get this mod working, but if it doesn't do that anyways, I'd like to know. |
|
|
|
 |
spasticdonkey
RavenNuke(tm) Development Team

Joined: Dec 02, 2006
Posts: 1693
Location: Texas, USA
|
Posted:
Wed May 20, 2009 8:18 pm |
|
no it wont alter images hosted elsewhere, only files attached to forums |
|
|
|
 |
FosgateElite

|
Posted:
Wed May 20, 2009 8:57 pm |
|
Dang it. Then it has been working like it was supposed to this whole time. lol
Ill be using the 3rd party mod above for this. Thanks! |
|
|
|
 |
FosgateElite

|
Posted:
Fri May 22, 2009 9:01 pm |
|
OK so here is the change code for that mod.
However, there are a few discrepancies in this code and in RN.
Can someone revise this to work with the current version of RN.
Code:
#
#-----[ SQL ]------------------------------------------
#
INSERT INTO rnuke_bbconfig( config_name, config_value ) VALUES ( 'postimg_width', '450' );
INSERT INTO rnuke_bbconfig( config_name, config_value ) VALUES ( 'postimg_height', '300' );
#
#-----[ OPEN ]------------------------------------------
#
includes/bbcode.php
#
#-----[ FIND ]------------------------------------------
#
$bbcode_tpl = null;
#
#-----[ AFTER, ADD ]------------------------------------------
#
// mod img size add
function makeimgsize ( $width, $height )
{
global $board_config;
$size = '';
// check for smallness
if ( $width < $board_config['postimg_width'] && $height < $board_config['postimg_height'] )
{
return 'SMALL';
}
elseif ( $width > $height )
{
if ( $board_config['postimg_width'] < $width )
{
$size = 'width="' . $board_config['postimg_width'] . '"';
}
}else
{
if ( $board_config['postimg_height'] < $height )
{
$size = 'height="' . $board_config['postimg_height'] . '"';
}
}
return $size;
}
function image_parse ( $post, $uid )
{
global $board_config, $lang, $bbcode_tpl;
preg_match_all( "/\[img(.*?):$uid\](.*?)\[\/img:$uid\]/i", $post, $matches);
foreach ( $matches[0] as $i => $img )
{
$stuff = $matches[1][$i];
$stuff = explode( ':', $stuff );
if ( count( $stuff ) != 4 )
{ // old image or something
$post = preg_replace( "#\[img:$uid\]([^?].*?)\[/img:$uid\]#i",
$bbcode_tpl['img'], $post );
}
switch($stuff[0])
{
case '=right':
$align = $lang['RIGHT'];
break;
case '=center':
$align = 'center';
break;
case '=left':
default:
$align = $lang['LEFT'];
break;
}
$width = $stuff[1];
$height = $stuff[2];
$size = makeimgsize( $width, $height );
if ( $size != 'SMALL' )
{
$replace = $bbcode_tpl['thmbimg'];
$seek = array( '{IMAGE}', '{WIDTH}', '{HEIGHT}', '{SIZE}', '{NOTICE}', '{ALIGN}' );
$with = ( !empty( $size ) ) ? array( $matches[2][$i] , $width,
$height, $size, $lang['postimg_clickme'], $align ) : array( $matches[2][$i] , $width, $height, $size, '', $align );
$replace = str_replace( $seek, $with, $replace );
}
else
{
$replace = str_replace( '\1', $matches[2][$i], $bbcode_tpl['img']
);
}
$post = str_replace( $img, $replace, $post );
}
return $post;
}
// mod img size end
#
#-----[ FIND ]------------------------------------------
#
$patterns[] = "#\[img:$uid\]([^?].*?)\[/img:$uid\]#i";
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// mod img size replace with call to image parsing function
$text = image_parse ( $text, $uid );
#
#-----[ FIND ]------------------------------------------
#
$text = preg_replace("#\[img\]
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// mod max img size changed the first pass thingo
preg_match_all( "#\[(img.*?)\]((http|ftp|https|ftps)://)([^ \?
&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]#sie", $text, $matches );
// now we go through these matches and do what's needed
foreach ( $matches[0] as $i => $m )
{
// easier use
$tag = $matches[1][$i];
$url1 = $matches[2][$i];
$url2 = $matches[4][$i];
// if we already tagged this one then we leave it be ;)
preg_match( '#img.*?:(\d+):(\d+)#i', $tag, $match );
if ( empty( $match ) )
{
// get the size so we can store it
if ( !$size = @getimagesize( $url1 . $url2 ) )
{ // image will not get resized
$width = '';
$height = '';
}
else
{
$width = $size[0];
$height = $size[1];
}
}
else
{ // we already have the size
$width = $match[1];
$height = $match[2];
}
$tag = explode( ':', $tag ); // remove any possible left over : stuff
$tag = $tag[0];
// lastly we replace it within the text
$text = str_replace( $m, '[' . $tag . ':' . $width . ':' . $height . ':' . $uid . ']' . $url1 . $url2 . '[/img:' . $uid . ']', $text );
}
#
#-----[ IN-LINE FIND ]------------------------------------------
#
$text
#
#-----[ IN-LINE BEFORE, ADD ]------------------------------------------
#
//
#
#-----[ AFTER, ADD ]------------------------------------------
#
// end mod img size changes
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/admin/admin_board.php
#
#-----[ FIND ]------------------------------------------
#
$namechange_no = ( !$new['allow_namechange'] ) ? "checked=\"checked\"" :
"";
#
#-----[ AFTER, ADD ]------------------------------------------
#
// mod img size add
$postimg_width = $new['postimg_width'];
$postimg_height = $new['postimg_height'];
// mod img size end
#
#-----[ FIND ]------------------------------------------
#
"L_RESET" => $lang['Reset'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
// mod img size add
"L_POSTIMG_SIZE" => $lang['postimg_size'],
"POSTIMG_WIDTH" => $postimg_width,
"POSTIMG_HEIGHT" => $postimg_height,
// mod img size end
#
#-----[ OPEN ]------------------------------------------
#
themes/Your Theme/forums or
templates/subSilver/bbcode.tpl
#
#-----[ FIND ]------------------------------------------
#
<!-- END email -->
#
#-----[ AFTER, ADD ]------------------------------------------
#
<!-- BEGIN thmbimg -->
<div align="{ALIGN}">
<table border="0">
<tr>
<td><img src="{IMAGE}" align="center" border="0" {SIZE}
onclick="window.open( '{IMAGE}', 'imgpop', 'width={WIDTH},height=
{HEIGHT},status=no,toolbar=no,menubar=no' );return false" /></td>
</tr>
<tr>
<td align="center" class="gensmall"><i>{NOTICE}</i></td>
</tr>
</table>
</div>
<!-- END thmbimg -->
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/templates/subSilver/admin/board_config_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<tr>
<td class="row1">{L_ENABLE_PRUNE}</td>
<td class="row2"><input type="radio" name="prune_enable" value="1"
{PRUNE_YES} /> {L_YES} <input type="radio" name="prune_enable" value="0"
{PRUNE_NO} /> {L_NO}</td>
</tr>
#
#-----[ AFTER, ADD ]------------------------------------------
#
<tr>
<td class="row1">{L_POSTIMG_SIZE}</td>
<td class="row2"><input type="text" size="5" maxlength="5"
name="postimg_width" value="{POSTIMG_WIDTH}" /> X <input type="text"
size="5" maxlength="5" name="postimg_height" value="{POSTIMG_HEIGHT}"
/></td>
</tr>
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// mod img size add
$lang['postimg_clickme'] = 'Thumbnail, click to enlarge.';
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/language/lang_english/lang_admin.php
#
#-----[ FIND ]------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// mod img size add
$lang['postimg_size'] = 'Maximum size of images in posts';
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
|
|
|
|
|
 |
FosgateElite

|
Posted:
Fri May 22, 2009 9:08 pm |
|
Actually, I may have just got this to work. The link isn't working but the shrink is. |
|
|
|
 |
FosgateElite

|
Posted:
Sun May 24, 2009 11:45 am |
|
FosgateElite wrote: | Actually, I may have just got this to work. The link isn't working but the shrink is. |
OK, i have fixed this. It was a word wrapping issue when copy and paste into code. Here is the final code.
MAKE SURE AFTER YOU COPY THE CODE YOU CORRECT ANY WORD WRAPPING THAT OCCURED DURING THE COPY.
Code:#
#-----[ SQL ]------------------------------------------
#
INSERT INTO rnuke_bbconfig( config_name, config_value ) VALUES ( 'postimg_width', '450' );
INSERT INTO rnuke_bbconfig( config_name, config_value ) VALUES ( 'postimg_height', '300' );
#
#-----[ OPEN ]------------------------------------------
#
includes/bbcode.php
#
#-----[ FIND ]------------------------------------------
#
$bbcode_tpl = null;
#
#-----[ AFTER, ADD ]------------------------------------------
#
// mod img size add
function makeimgsize ( $width, $height )
{
global $board_config;
$size = '';
// check for smallness
if ( $width < $board_config['postimg_width'] && $height < $board_config['postimg_height'] )
{
return 'SMALL';
}
elseif ( $width > $height )
{
if ( $board_config['postimg_width'] < $width )
{
$size = 'width="' . $board_config['postimg_width'] . '"';
}
}else
{
if ( $board_config['postimg_height'] < $height )
{
$size = 'height="' . $board_config['postimg_height'] . '"';
}
}
return $size;
}
function image_parse ( $post, $uid )
{
global $board_config, $lang, $bbcode_tpl;
preg_match_all( "/\[img(.*?):$uid\](.*?)\[\/img:$uid\]/i", $post, $matches);
foreach ( $matches[0] as $i => $img )
{
$stuff = $matches[1][$i];
$stuff = explode( ':', $stuff );
if ( count( $stuff ) != 4 )
{ // old image or something
$post = preg_replace( "#\[img:$uid\]([^?].*?)\[/img:$uid\]#i", $bbcode_tpl['img'], $post );
}
switch($stuff[0])
{
case '=right':
$align = $lang['RIGHT'];
break;
case '=center':
$align = 'center';
break;
case '=left':
default:
$align = $lang['LEFT'];
break;
}
$width = $stuff[1];
$height = $stuff[2];
$size = makeimgsize( $width, $height );
if ( $size != 'SMALL' )
{
$replace = $bbcode_tpl['thmbimg'];
$seek = array( '{IMAGE}', '{WIDTH}', '{HEIGHT}', '{SIZE}', '{NOTICE}', '{ALIGN}' );
$with = ( !empty( $size ) ) ? array( $matches[2][$i] , $width, $height, $size, $lang['postimg_clickme'], $align ) : array( $matches[2][$i] , $width, $height, $size, '', $align );
$replace = str_replace( $seek, $with, $replace );
}
else
{
$replace = str_replace( '\1', $matches[2][$i], $bbcode_tpl['img'] );
}
$post = str_replace( $img, $replace, $post );
}
return $post;
}
// mod img size end
#
#-----[ FIND ]------------------------------------------
#
$patterns[] = "#\[img:$uid\]([^?](?:[^\[]+|\[(?!url))*?)\[/img:$uid\]#i";
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// mod img size replace with call to image parsing function
$text = image_parse ( $text, $uid );
#
#-----[ FIND ]------------------------------------------
#
$text = preg_replace("#\[img\]
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// mod max img size changed the first pass thingo
preg_match_all( "#\[(img.*?)\]((http|ftp|https|ftps)://)([^ \?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]#sie", $text, $matches );
// now we go through these matches and do what's needed
foreach ( $matches[0] as $i => $m )
{
// easier use
$tag = $matches[1][$i];
$url1 = $matches[2][$i];
$url2 = $matches[4][$i];
// if we already tagged this one then we leave it be ;)
preg_match( '#img.*?:(\d+):(\d+)#i', $tag, $match );
if ( empty( $match ) )
{
// get the size so we can store it
if ( !$size = @getimagesize( $url1 . $url2 ) )
{ // image will not get resized
$width = '';
$height = '';
}
else
{
$width = $size[0];
$height = $size[1];
}
}
else
{ // we already have the size
$width = $match[1];
$height = $match[2];
}
$tag = explode( ':', $tag ); // remove any possible left over : stuff
$tag = $tag[0];
// lastly we replace it within the text
$text = str_replace( $m, '[' . $tag . ':' . $width . ':' . $height . ':' . $uid . ']' . $url1 . $url2 . '[/img:' . $uid . ']', $text );
}
#
#-----[ IN-LINE FIND ]------------------------------------------
#
$text
#
#-----[ IN-LINE BEFORE, ADD ]------------------------------------------
#
//
#
#-----[ AFTER, ADD ]------------------------------------------
#
// end mod img size changes
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/admin/admin_board.php
#
#-----[ FIND ]------------------------------------------
#
$namechange_no = ( !$new['allow_namechange'] ) ? "checked=\"checked\"" : "";
#
#-----[ AFTER, ADD ]------------------------------------------
#
// mod img size add
$postimg_width = $new['postimg_width'];
$postimg_height = $new['postimg_height'];
// mod img size end
#
#-----[ FIND ]------------------------------------------
#
"L_RESET" => $lang['Reset'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
// mod img size add
"L_POSTIMG_SIZE" => $lang['postimg_size'],
"POSTIMG_WIDTH" => $postimg_width,
"POSTIMG_HEIGHT" => $postimg_height,
// mod img size end
#
#-----[ OPEN ]------------------------------------------
#
themes/Your Theme/forums or
templates/subSilver/bbcode.tpl
#
#-----[ FIND ]------------------------------------------
#
<!-- END email -->
#
#-----[ AFTER, ADD ]------------------------------------------
#
<!-- BEGIN thmbimg -->
<div align="{ALIGN}">
<table border="0">
<tr>
<td><img src="{IMAGE}" align="center" border="0" {SIZE} onclick="window.open( '{IMAGE}', 'imgpop', 'width={WIDTH},height={HEIGHT},status=no,toolbar=no,menubar=no' );return false" /></td>
</tr>
<tr>
<td align="center" class="gensmall"><i>{NOTICE}</i></td>
</tr>
</table>
</div>
<!-- END thmbimg -->
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/templates/subSilver/admin/board_config_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<tr>
<td class="row1">{L_ENABLE_PRUNE}</td>
<td class="row2"><input type="radio" name="prune_enable" value="1" {PRUNE_YES} /> {L_YES} <input type="radio" name="prune_enable" value="0" {PRUNE_NO} /> {L_NO}</td>
</tr>
#
#-----[ AFTER, ADD ]------------------------------------------
#
<tr>
<td class="row1">{L_POSTIMG_SIZE}</td>
<td class="row2"><input type="text" size="5" maxlength="5" name="postimg_width" value="{POSTIMG_WIDTH}" /> X <input type="text" size="5" maxlength="5" ame="postimg_height" value="{POSTIMG_HEIGHT}" /></td>
</tr>
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// mod img size add
$lang['postimg_clickme'] = 'Thumbnail, click to enlarge.';
#
#-----[ OPEN ]------------------------------------------
#
modules/Forums/language/lang_english/lang_admin.php
#
#-----[ FIND ]------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// mod img size add
$lang['postimg_size'] = 'Maximum size of images in posts';
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
|
|
|
|
|
 |
kenspa
Hangin' Around

Joined: Sep 24, 2005
Posts: 48
Location: Spain
|
Posted:
Sun May 31, 2015 1:35 am |
|
This is a great addition to the forum!!
There is one thing to fix: width is updated when changed in the fórum general settings, but the height keeps the same value set on the first insert in sql!!
cheers |
|
|
|
 |
nuken
RavenNuke(tm) Development Team

Joined: Mar 11, 2007
Posts: 2024
Location: North Carolina
|
Posted:
Tue Jun 02, 2015 9:22 pm |
|
I just added Code:.postbody img{max-width:700px}
| to my ravennuke.css and any image posted in the forums will not be any larger than 700px wide and the height scales to the width. |
_________________ Only registered users can see links on this board! Get registered or login! |
|
|
 |
Doulos
Life Cycles Becoming CPU Cycles

Joined: Jun 06, 2005
Posts: 732
|
Posted:
Fri Feb 17, 2017 5:34 am |
|
I'm trying to get attachments to resize but none of the above are working. Any suggestions? |
|
|
|
 |
kguske
Site Admin

Joined: Jun 04, 2004
Posts: 6437
|
Posted:
Fri Feb 17, 2017 11:12 am |
|
I'd suggest the CSS approach to limit the size. It won't resize if the image is smaller than the limit. You'll also need to refresh the page to load the new CSS. |
_________________ I search, therefore I exist...
Only registered users can see links on this board! Get registered or login! |
|
|
 |
Doulos

|
Posted:
Sat Feb 18, 2017 5:57 pm |
|
It appears that the do not resize in some themes, some the do. |
|
|
|
 |
|