Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Beta Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Check for valid linked image and resize if too large Details »»
Check for valid linked image and resize if too large
Version: 1.00, by Locutus2999 Locutus2999 is offline
Developer Last Online: Jan 2011 Show Printable Version Email this Page

Version: 2.3.x Rating:
Released: 05-26-2003 Last Update: Never Installs: 3
Is in Beta Stage  
No support by the author.

I hate it when users link to images that are really large and cause the layout of the site to become all distorted. It's also annoying to see the image placeholder and the red "X" whenever the site hosting an image is unavailable.

This check will check the width of a linked image and if it's wider than the size you would like to allow, it will add a width attribute to the <img> tag so it will be resized. If the image is not available on the linked site, then it will display a message saying the linked image is currenty unavailable.

It only requires an edit to admin/functions.php.

Open functions.php and find the following line:

PHP Code:
$bbcode preg_replace("/\[img\](\r\n|\r|\n)*((http|https):\/\/([^;<>\(\)\"".iif($allowdynimg,"","!\*\?\&")."]+)|[a-z0-9\/\\\._\- ]+)\[\/img\]/siU""<img src=\"\\2\" border=\"0\" alt=\"\">"$bbcode); 
REPLACE it with the following code:

PHP Code:
      if (strstr($bbcode"[img]")) {
          
ob_start();
          
$img_url=preg_replace("/\[img\](\r\n|\r|\n)*((http|https):\/\/([^;<>\(\)\"".iif($allowdynimg,"","!\*\?\&")."]+)|[a-z0-9\/\\\._\- ]+)\[\/img\]/siU""\\2"$bbcode);
          
$img_url=trim(ereg_replace('<[^>]*>'''$img_url));

          
$img_size getimagesize($img_url,$info);
          if (
$img_size==false$dont_display=true;
          
ob_end_clean();
      }
      if (
$img_size[0]> 400) {
          
$bbcode preg_replace("/\[img\](\r\n|\r|\n)*((http|https):\/\/([^;<>\(\)\"".iif($allowdynimg,"","!\*\?\&")."]+)|[a-z0-9\/\\\._\- ]+)\[\/img\]/siU""<img src=\"\\2\" border=\"0\" width=\"400\" alt=\"\">"$bbcode);
      } else {
          
$bbcode preg_replace("/\[img\](\r\n|\r|\n)*((http|https):\/\/([^;<>\(\)\"".iif($allowdynimg,"","!\*\?\&")."]+)|[a-z0-9\/\\\._\- ]+)\[\/img\]/siU""<img src=\"\\2\" border=\"0\" alt=\"\">"$bbcode);
      }
      if (
$dont_display==true$bbcode="<br><i>".htmlentities("<linked image unavailable>")."</i>";
    } 

Replace $img_size[0]> 400 & width=\"400\" with the your max width and that's it.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #32  
Old 01-19-2004, 01:11 PM
Aaron1's Avatar
Aaron1 Aaron1 is offline
 
Join Date: Oct 2002
Location: Amsterdam
Posts: 200
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I was just thinking, if you can automatically add this onload function below in the IMG tag, the resizing of the imageswill crossbrowser friendly.

Quote:
<img src="http://www.vbulletin.org/layout/header.gif" OnLoad='if(this.width > 580 || this.height > 435) if((this.width / this.height) > (580/435)) {this.width=580} else {this.height=435}'>
Where 580 is the maximum width the picture will appear, the only thing it lacks is the link to the pop-up with the original picture..

Can somebody try to get this working properly pehaps? I am not a script wizard
Reply With Quote
  #33  
Old 02-01-2004, 12:36 PM
Royal's Avatar
Royal Royal is offline
 
Join Date: Jan 2002
Location: Netherlands
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yea im also looking for the fix

i tried it myself but i cant seem to find it
Reply With Quote
  #34  
Old 05-25-2004, 03:57 PM
aakk aakk is offline
 
Join Date: Feb 2004
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

works great! thanks!!!
Reply With Quote
  #35  
Old 07-08-2005, 09:06 PM
94supratt 94supratt is offline
 
Join Date: Dec 2002
Posts: 60
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by QiQme
Hi,

I use the following file as the solution.

I'm sure someone here can make this better but it's a start.

In the zip file is a image.js and a html file as an example.

Greetz
Works awesome!
Reply With Quote
  #36  
Old 08-20-2005, 01:49 AM
94supratt 94supratt is offline
 
Join Date: Dec 2002
Posts: 60
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by TheLab
QiQme thats a great idea and it works great on IE, but not on Netscape/Opera/Mozilla. Is there any code fix for this?

Any fix? Works fine in IE but not Mozilla.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:44 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04403 seconds
  • Memory Usage 2,269KB
  • Queries Executed 20 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (5)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete