Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Beta Releases

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
  #22  
Old 01-02-2004, 10:14 PM
Xxman's Avatar
Xxman Xxman is offline
 
Join Date: Aug 2002
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Cool ! I'll try it .
Thanks.
Reply With Quote
  #23  
Old 01-08-2004, 12:32 PM
Royal's Avatar
Royal Royal is offline
 
Join Date: Jan 2002
Location: Netherlands
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i saw this option on an other dutch forum (not vbulletin) isnt is posible to make the hack like this :

http://forum.fok.nl/showtopic.php/447356


so when u click on it that it opens in a popup with a clickable close on it

this is what QiQme is meaning
Reply With Quote
  #24  
Old 01-09-2004, 10:49 PM
Xxman's Avatar
Xxman Xxman is offline
 
Join Date: Aug 2002
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Xxman
Cool ! I'll try it .
Damn! It doesent work for me on Vbulletin..

I put this :
PHP Code:
<script type="text/javascript" src="http://www.mysite.com/portal/image.js"></script
into my vbulletin header template and this :
PHP Code:
<SCRIPT language=javascript>check_images();</SCRIPT
into my vbulletin footer template after uploaded image.js into www.mysite.com/portal folder..

Why not work ??

QiQme , what does it mean this piece of code?
PHP Code:
if(!url.match(/vwforum.nl/) && !url.match(/athena.webmagix.net/)){ 
Reply With Quote
  #25  
Old 01-13-2004, 07:28 PM
Xxman's Avatar
Xxman Xxman is offline
 
Join Date: Aug 2002
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

..anybody ?
Reply With Quote
  #26  
Old 01-16-2004, 10:25 AM
Aaron1's Avatar
Aaron1 Aaron1 is offline
 
Join Date: Oct 2002
Location: Amsterdam
Posts: 200
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am in the dark too XXman, i would love to see this hack work properly too.

The example over at: http://forum.fok.nl/showtopic.php/447356
Is exaclty how it should be done, although i really have no clue how they have done that, or how to incorporate it into vbulletin.

So if someone could help us out i would be eternally gratefull!
Reply With Quote
  #27  
Old 01-17-2004, 12:52 PM
QiQme QiQme is offline
 
Join Date: Apr 2002
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Xxman
Damn! It doesent work for me on Vbulletin..

I put this :
PHP Code:
<script type="text/javascript" src="http://www.mysite.com/portal/image.js"></script
into my vbulletin header template and this :
PHP Code:
<SCRIPT language=javascript>check_images();</SCRIPT
into my vbulletin footer template after uploaded image.js into www.mysite.com/portal folder..

Why not work ??

QiQme , what does it mean this piece of code?
PHP Code:
if(!url.match(/vwforum.nl/) && !url.match(/athena.webmagix.net/)){ 
Just change vwforum.nl and athena.webmagix.net to yoursite.com
Reply With Quote
  #28  
Old 01-17-2004, 12:55 PM
QiQme QiQme is offline
 
Join Date: Apr 2002
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In the attachement ( https://vborg.vbsupport.ru/showpost....3&postcount=16 ) you can see that it works.

There's just nothing more to say about it i think.
Reply With Quote
  #29  
Old 01-17-2004, 02:06 PM
Aaron1's Avatar
Aaron1 Aaron1 is offline
 
Join Date: Oct 2002
Location: Amsterdam
Posts: 200
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey thanks!

That works perfect, well almost it does, the only problem i have now is that the pop-up has some white space above the enlarged image. Strange, although the pop-ups on the the example page: http://forum.fok.nl/showtopic.php/447356

Doesn't have that ugly whitespace. Any clues?

Hmm, i just checked and i think they used an image.php document, with unknown contents...

Also on your example zip file, the image in the pop-up is cropped somehow, it doesn't show the complete image... Argh
Reply With Quote
  #30  
Old 01-17-2004, 03:37 PM
Xxman's Avatar
Xxman Xxman is offline
 
Join Date: Aug 2002
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by QiQme
Just change vwforum.nl and athena.webmagix.net to yoursite.com
I'm a fool ..
Reply With Quote
  #31  
Old 01-18-2004, 01:08 PM
TheLab TheLab is offline
 
Join Date: May 2003
Posts: 88
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

QiQme thats a great idea and it works great on IE, but not on Netscape/Opera/Mozilla. Is there any code fix for this?
Reply With Quote
Reply

Thread Tools

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 05:27 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.13071 seconds
  • Memory Usage 2,327KB
  • Queries Executed 25 (?)
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
  • (8)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
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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