Jump to content
InvisionCommunity.de - Der Deutsche Invision Community Support
Sign in to follow this  
Orthodoxboy

Grafiken automatisch verkleinern

Recommended Posts

Hallo,

gibt es eine Möglichkeit dass Grafiken die das Forumlayot sprengen automatisch auf eine bestimmte größe verkleinert werden?

z.B. alle bilder die breiter als 600px sind werden verkleinert.

Gruß,

Boki

Share this post


Link to post

Der hier: http://mods.invisionize.com/db/index.php/f/5417

/*

+-------------------------------------------------------------------

| Invision Power Board 2.1 Modification

| Provided as is, use at your own risk

|

| Automatic Resize [IMG] [/IMG] in topics

| By: Lateralus

| Orignal Code (for IPB 2.0.x) By: BigBallerAlwayz

| Orignal Code (for IPB 1.3) By: Quang Trung

+--------------------------------------------------------------------

*/


- What does this mod do?


This modification resizes images that use the bbcode [IMG] [/IMG] 

to the size defined by "Attachment thumbnail size" inside of the

Admin Cpanel. The image will be clickable and launch in new window

if user(s) wishes to view the full image.


This allows forums to maintain orignal look and allow topics to load

much faster then before. This is a 2.1 mod but is also available for

2.0 (by BigBallerAlwayz) and 1.3 (by Quang Trung).


It is a small three files modification.


- Files to edit

sources/classes/bbcode/class_bbcode.php

sources/classes/bbcode/class_bbcode_core.php

sources/classes/bbcode/class_bbcode_legacy.php


//-------------------------------------------------------------------

//-------------------------------------------------------------------


/*in file: sources/classes/bbcode/class_bbcode.php*/

FIND [in function pre_edit_parse()]:


 	 $txt = preg_replace( "#<img src=[\"'](\S+?)['\"].+?".">#"      , "\[img\]\\1\[/img\]"            , $txt );

 	 

ADD below:

 	 $txt = preg_replace( "#<!--ImageUrlBegin-->(.+?)<!--ImageUrlEBegin-->#"                , ''         , $txt );

 	 $txt = preg_replace( "#<!--ImageUrlEnd-->(.+?)<!--ImageUrlEEnd-->#"                , ''         , $txt );

 	 $txt = preg_replace( "#<img .+? src=[\"'](\S+?)['\"].+?".">#"           , "\[img\]\\1\[/img\]"            , $txt );

 	 



/*in file: sources/classes/bbcode/class_bbcode_legacy.php*/

Find [in function pre_edit_parse()]:

 	 $txt = preg_replace( "#<img src=[\"'](\S+?)['\"].+?".">#"      , "\[img\]\\1\[/img\]"            , $txt );

ADD below:

 	 $txt = preg_replace( "#<!--ImageUrlBegin-->(.+?)<!--ImageUrlEBegin-->#"                , ''         , $txt );

 	 $txt = preg_replace( "#<!--ImageUrlEnd-->(.+?)<!--ImageUrlEEnd-->#"                , ''         , $txt );

 	 $txt = preg_replace( "#<img .+? src=[\"'](\S+?)['\"].+?".">#"           , "\[img\]\\1\[/img\]"            , $txt );



/*in file: sources/classes/bbcode/class_bbcode_core.php*/

FIND [in function regex_check_image()]:


 	 return "<img src=\"$url\" border=\"0\" alt=\"{$this->ipsclass->lang['bbcode_img_alt']}\" />";


REPLACE with:


  // START Image Auto Resize Mod

        $qt_maxwidth = $this->ipsclass->vars['siu_width'];

  $qt_img_info = getimagesize("$url");

        $qt_out_width = 0;


        if ( $qt_img_info[0] >  $qt_maxwidth )

  {

       	 $qt_out_width = $qt_maxwidth;

 	 return "<!--ImageUrlBegin--><a href=\"$url\" target=\"_new\"><!--ImageUrlEBegin--><img width=\"$qt_out_width\" class=\"attach\" src=\"$url\" border='0' alt=\"{$this->ipsclass->lang['bbcode_img_alt']}\" /><!--ImageUrlEnd--></a><!--ImageUrlEEnd--><br />";

        }

  else return "<img src=\"$url\" border=\"0\" alt=\"{$this->ipsclass->lang['bbcode_img_alt']}\" />";

  // END Image Auto Resize Mod	



Save & upload all the edited files


And you're done :)

Demo: http://www.gamereplays.org/community/Testing_the_new_img_resize_mod-t31427.html

And visit Invisionize of course for support :)

Edited by kdt

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×