Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> v2.30.01 RN All Other Issues
Author Message
FosgateElite
Regular
Regular



Joined: Mar 26, 2006
Posts: 63

PostPosted: Mon Apr 27, 2009 10:45 am Reply with quote

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?
 
View user's profile Send private message
jakec
Site Admin



Joined: Feb 06, 2006
Posts: 3048
Location: United Kingdom

PostPosted: Mon Apr 27, 2009 11:20 am Reply with quote

Doesn't the forum attachment mod that comes with RN do this?
 
View user's profile Send private message
FosgateElite







PostPosted: Tue Apr 28, 2009 6:55 pm Reply with quote

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







PostPosted: Wed Apr 29, 2009 12:15 am Reply with quote

I personally don't use it, but that is my understanding, I could be wrong of course. Give it a test run and see. Wink


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

PostPosted: Wed Apr 29, 2009 2:05 am Reply with quote

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: http://www.rogbbtonukemods.com/modules.php?name=Downloads&d_op=getit&lid=169

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.
 
View user's profile Send private message
dad7732
RavenNuke(tm) Development Team



Joined: Mar 18, 2007
Posts: 1242

PostPosted: Tue May 05, 2009 11:55 am Reply with quote

The attachemt feature in "forums" will do this, but only for attached images using that feature.

Forums => Attachments => Management => Attachment Filesize Settings
 
View user's profile Send private message
FosgateElite







PostPosted: Tue May 05, 2009 2:49 pm Reply with quote

Yeah, I played with those settings a bunch but I think my theme is keeping it from working correctly.
 
FosgateElite







PostPosted: Sat May 09, 2009 5:33 pm Reply with quote

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: http://www.rogbbtonukemods.com/modules.php?name=Downloads&d_op=getit&lid=169

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







PostPosted: Sat May 09, 2009 5:48 pm Reply with quote

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







PostPosted: Sat May 09, 2009 7:55 pm Reply with quote

This was a fresh install. Was that part of the fresh install steps?
 
dad7732







PostPosted: Sat May 09, 2009 8:16 pm Reply with quote

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







PostPosted: Sat May 09, 2009 10:21 pm Reply with quote

Ill try the htaccess change.
I dont get any errors, images just never resize and link...
 
sockettf







PostPosted: Sun May 10, 2009 2:11 am Reply with quote

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 --> Here

Also, you can view the mod working --> here
 
FosgateElite







PostPosted: Sun May 10, 2009 8:48 pm Reply with quote

Perfect. That looks just like the one I used in the past. Thanks a TON!
 
FosgateElite







PostPosted: Wed May 20, 2009 7:33 pm Reply with quote

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

PostPosted: Wed May 20, 2009 8:18 pm Reply with quote

no it wont alter images hosted elsewhere, only files attached to forums
 
View user's profile Send private message Visit poster's website
FosgateElite







PostPosted: Wed May 20, 2009 8:57 pm Reply with quote

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







PostPosted: Fri May 22, 2009 9:01 pm Reply with quote

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







PostPosted: Fri May 22, 2009 9:08 pm Reply with quote

Actually, I may have just got this to work. The link isn't working but the shrink is.
 
FosgateElite







PostPosted: Sun May 24, 2009 11:45 am Reply with quote

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

PostPosted: Sun May 31, 2015 1:35 am Reply with quote

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
 
View user's profile Send private message
nuken
RavenNuke(tm) Development Team



Joined: Mar 11, 2007
Posts: 2024
Location: North Carolina

PostPosted: Tue Jun 02, 2015 9:22 pm Reply with quote

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.

_________________
Tricked Out News 
View user's profile Send private message Send e-mail Visit poster's website
Doulos
Life Cycles Becoming CPU Cycles



Joined: Jun 06, 2005
Posts: 732

PostPosted: Fri Feb 17, 2017 5:34 am Reply with quote

I'm trying to get attachments to resize but none of the above are working. Any suggestions?
 
View user's profile Send private message
kguske
Site Admin



Joined: Jun 04, 2004
Posts: 6432

PostPosted: Fri Feb 17, 2017 11:12 am Reply with quote

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...
nukeSEO - nukeFEED - nukePIE - nukeSPAM - nukeWYSIWYG
 
View user's profile Send private message
Doulos







PostPosted: Sat Feb 18, 2017 5:57 pm Reply with quote

It appears that the do not resize in some themes, some the do.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> v2.30.01 RN All Other Issues

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©