Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.5 > vBulletin 3.5 Add-ons

Reply
 
Thread Tools
Image resize on non hosted images Details »»
Image resize on non hosted images
Version: 1.00, by vtx1800 vtx1800 is offline
Developer Last Online: Feb 2012 Show Printable Version Email this Page

Version: 3.5.3 Rating:
Released: 01-21-2006 Last Update: Never Installs: 1
Code Changes  
No support by the author.

This is my first attempt on vB code changes, so I hope this works. I also believe this should be a vB ACP feature in the near future.

Credit: I was reading this thread and decided to make this hack. I used it as a place to start and make my version.

What this does: What this will do is restrict images that a user posts that are not hosted on a user defined server.

1. All images not hosted on a defined server will be set to 100x100.
2. User can set the host domain to allow normal image sizes.

Reason for this: I wanted this code to prevent a user from posting a huge image and cause the forum layout to get destroyed. I hated it when a image size of 1024x768 gets posted and my forums width is only 700px.

To install: I don't know how to make a plugin, so it's all via editing the "class_bbcode.php" file in the /includes folder.

Find: (Line 1828)

Code:
return '<img src="' .  $link . '" border="0" alt="" />';
Replace with: (Note this must be enclosed with the {} to work.)
Code:
{if (preg_match("/allowedDomain.com/i", $link)) 
			{
   			return '<img src="' .  $link . '" border="1" />';
			} else {
  			return '<img src="' .  $link . '" border="1" height="100" width="100" />';
			}
You must change the "allowedDomain" text to be the site you want to allow. So, if you want to allow http://www.putfile.com, do not include the 'http' or 'www'.

Hope this is useful to all of you, I know it's something I was looking for, but never found. If it is on the site, sorry, I can't seem to find much with the search feature.

If you like it, please click INSTALL if you use it.

All comments are welcome, as this was my first attempt and would like to make more.

Show Your Support

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

Comments
  #2  
Old 01-22-2006, 01:55 AM
evenmonkeys's Avatar
evenmonkeys evenmonkeys is offline
 
Join Date: Aug 2004
Location: Iowa
Posts: 896
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm going to test this out, but it looks like it will effect signatures.
Reply With Quote
  #3  
Old 01-22-2006, 02:00 AM
evenmonkeys's Avatar
evenmonkeys evenmonkeys is offline
 
Join Date: Aug 2004
Location: Iowa
Posts: 896
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

HTML Code:
error: parse error, unexpected T_IF, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /html/includes/class_bbcode.php on line 1971
Reply With Quote
  #4  
Old 01-22-2006, 02:05 AM
vtx1800 vtx1800 is offline
 
Join Date: Nov 2005
Location: California
Posts: 36
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You are missing the { and } to surround the IF statement.

This is a copy of my code... a few line above and below of the original insert.

Code:
	* @param	string	The URL to the image.
	*
	* @return	string	HTML representation of the tag.
	*/
	function handle_bbcode_img_match($link)
	{
		$link = $this->strip_smilies(str_replace('\\"', '"', $link));

		// remove double spaces -- fixes issues with wordwrap
		$link = str_replace('  ', '', $link);
		
		{if (preg_match("/yourDomain.com/i", $link)) 
			{
   			return '<img src="' .  $link . '" border="1" />';
			} else {
  			return '<img src="' .  $link . '" border="1" height="100" width="100" />';
			}
			}
		# return '<img src="' .  $link . '" border="0" alt="" />';
	}

	/**
	* Removes the specified amount of line breaks from the front and/or back
	* of the input string. Includes HTML line braeks.
Note, I kept the old original code, just added the '#' to block the line.

UPDATE: I just checked the test posts, it appears it will effect the signatures. I'll update it to not effect sigs later tonight.

UPDATE 2: I found out why my test didn't catch the sig images... I have a custom BB code for Sig images.
Reply With Quote
  #5  
Old 01-22-2006, 07:51 AM
evenmonkeys's Avatar
evenmonkeys evenmonkeys is offline
 
Join Date: Aug 2004
Location: Iowa
Posts: 896
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah. I've got that same problem. I've been trying to seperate posts from signatures... but can't.
Reply With Quote
  #6  
Old 01-22-2006, 08:51 AM
Snake's Avatar
Snake Snake is offline
 
Join Date: Mar 2005
Location: Cleveland, OH
Posts: 3,832
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Definitely going to install this once I get back to home!
Reply With Quote
  #7  
Old 01-22-2006, 09:03 PM
RyanC RyanC is offline
 
Join Date: Jan 2005
Posts: 77
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is there anyway to do this just by width so that the image doesn't lose aspect ratio? I hate it when folks break my designs with big ole images, but I don't want to torture their images either... just curious.

thanks!
Reply With Quote
  #8  
Old 01-22-2006, 09:06 PM
vtx1800 vtx1800 is offline
 
Join Date: Nov 2005
Location: California
Posts: 36
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think the other hack, https://vborg.vbsupport.ru/showthrea...ght=image+size might work better for you.

I wanted it to crush them down, so the users knew that the image was not hosted on our servers, and if anything adult was posted, it wouldn't be as noticable.

I am working on this now, to prevent the signature images being effected.
Reply With Quote
  #9  
Old 01-24-2006, 05:29 AM
Zia's Avatar
Zia Zia is offline
 
Join Date: Dec 2005
Location: golpo.net
Posts: 931
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

helo....
just let me a bit more clear....xplaining

In our forum: we use imageshack.us & photobucket.com 's free image host service..

will this hack create all the image hosted on those both place to thumbnail ?
and it should not touch the sigs that also hosted on photobucket/imageshack?

will this hack only works on pre-define domain? wont it work on universal??

Waiting for some xplanation...

Thankx
Reply With Quote
  #10  
Old 01-24-2006, 05:34 AM
vtx1800 vtx1800 is offline
 
Join Date: Nov 2005
Location: California
Posts: 36
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Zia
helo....
just let me a bit more clear....xplaining

In our forum: we use imageshack.us & photobucket.com 's free image host service..

will this hack create all the image hosted on those both place to thumbnail ?
and it should not touch the sigs that also hosted on photobucket/imageshack?

will this hack only works on pre-define domain? wont it work on universal??

Waiting for some xplanation...


Thankx
At the moment, this will make a thumbnail of any image used in the [img] tag. So yes, sigs are included.

I have code for just the users posts, but it's causing an error in the quick reply of 3.5.3. The new code, not yet posted, does work with only the posts, and not the sigs, but the quickreply error is slowing me down.

I hope to have the 2nd code up soon, once I find out why the error is being generated.
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 12:05 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04619 seconds
  • Memory Usage 2,295KB
  • Queries Executed 23 (?)
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
  • (3)bbcode_code
  • (1)bbcode_html
  • (1)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
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)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