Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.6 > vBulletin 3.6 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Auto Resize images when Quoted Details »»
Auto Resize images when Quoted
Version: 1.00, by rokked rokked is offline
Developer Last Online: Apr 2008 Show Printable Version Email this Page

Category: New Posting Features - Version: 3.6.8 Rating:
Released: 04-25-2007 Last Update: Never Installs: 21
Re-useable Code Code Changes  
No support by the author.

Auto Resize Images when they're Quoted
Test with: 3.6.5

This is a pretty basic add on and also my first add on. If you see anything messed up in the code or something that could be done better, please comment and I'll fix it. I'm relatively new to the add-on scene, so there could be better ways to do this.

What does this mod do?
images that get posted within the QUOTE tag will be resized to a width of 100.
thumbnails will link to the url of the actual image.

Installation:
open includes/class_bbcode.php

find:
Code:
$template = $this->printable ? 'bbcode_quote_printable' : 'bbcode_quote';
eval('$html = "' . fetch_template($template) . '";');
return $html;
	}
replace with:
Code:
$template = $this->printable ? 'bbcode_quote_printable' : 'bbcode_quote';
		eval('$html = "' . fetch_template($template) . '";');
		//### RESIZE IMAGES IN QUOTE TAGS
		if ($this->contains_bbcode_img_tags($html)) 
		{
			$html = preg_replace('#\[img\]\s*(https?://([^<>*"]+|[a-z0-9/\\._\- !]+))\[/img\]#iUe', "\$this->handle_bbcode_timg(str_replace('\\\"', '\"', '\\1'), '')", $html);
		}
		//### RESIZE IMAGES IN QUOTE
               	return $html;
	}
find:
Code:
function handle_bbcode_img_match($link)
	{
		$link = $this->strip_smilies(str_replace('\\"', '"', $link));

		// remove double spaces -- fixes issues with wordwrap
		$link = str_replace('  ', '', $link);

		return '<img src="' .  $link . '" border="0" alt="" />';
	}
underneath that paste the following:
Code:
function handle_bbcode_timg($link)
        {
                $link = $this->strip_smilies(str_replace('\\"', '"', $link));

		// remove double spaces -- fixes issues with wordwrap
		$link = str_replace('  ', '', $link);

		return '<a href="' .  $link . '" target="_blank"><img src="' .  $link . '" border="0" width="100" alt="" /></a>';
	}
Save & Upload.

That should be it. Hopefully it works for you!

Show Your Support

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

Comments
  #12  
Old 04-13-2008, 02:38 AM
JKatz JKatz is offline
 
Join Date: Nov 2007
Location: USA
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Will this work with 3.6.9?
Reply With Quote
  #13  
Old 04-13-2008, 08:38 AM
mahsazn mahsazn is offline
 
Join Date: Feb 2008
Posts: 37
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

what a good idea! i'll try it too...
Reply With Quote
  #14  
Old 01-31-2010, 02:14 AM
pablete pablete is offline
 
Join Date: Feb 2009
Posts: 99
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This mod work for vb4?

Thank's
Reply With Quote
  #15  
Old 06-05-2012, 10:35 PM
PinkMilk PinkMilk is offline
 
Join Date: May 2010
Location: Earth
Posts: 193
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Get Shorty View Post
I changed this to resize to 200 pixels...

It would be great if it didn't increase the size of small images.
Quote:
Originally Posted by arco View Post
I'll second that. Looks kinda silly.

I think changing to a link would be better, this way no small images are enlarged and saves even more space.

In the last code box find:
PHP Code:
return '<a href="' .  $link '" target="_blank"><img src="' .  $link '" border="0" width="100" alt="" /></a>'
Replace with:
PHP Code:
return '<a href="' .  $link '" target="_blank">' .  $link '</a>'
Not tested but should work
Reply With Quote
  #16  
Old 06-23-2012, 10:44 AM
Crimdog Crimdog is offline
 
Join Date: Dec 2007
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by PinkMilk View Post
I think changing to a link would be better, this way no small images are enlarged and saves even more space.

In the last code box find:
PHP Code:
return '<a href="' .  $link '" target="_blank"><img src="' .  $link '" border="0" width="100" alt="" /></a>'
Replace with:
PHP Code:
return '<a href="' .  $link '" target="_blank">' .  $link '</a>'
Not tested but should work
PinkMilk -

Is there any way you could modify this to return an if/then statement? I am using your modification above, but users are complaining and want to have the first image or two displayed as images, and the rest displayed as links. Is this easily possible?
Reply With Quote
  #17  
Old 06-25-2012, 11:23 PM
PinkMilk PinkMilk is offline
 
Join Date: May 2010
Location: Earth
Posts: 193
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

@Crimdog: Sorry that's a little out of my PHP knowledge, good idea though.
Reply With Quote
  #18  
Old 06-26-2012, 12:32 AM
christon26 christon26 is offline
 
Join Date: Dec 2008
Location: Australia
Posts: 174
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Get Shorty View Post
I changed this to resize to 200 pixels...

It would be great if it didn't increase the size of small images.
Change
Quote:
return '<a href="' . $link . '" target="_blank"><img src="' . $link . '" border="0" width="100" alt="" /></a>';
to

Quote:
return '<a href="' . $link . '" target="_blank"><img src="' . $link . '" border="0" style="max-width: 100px;" alt="" /></a>';
and that should do it, change the 100px to whatever size you want it to be
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 02:12 PM.


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.08386 seconds
  • Memory Usage 2,293KB
  • Queries Executed 24 (?)
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
  • (4)bbcode_code
  • (4)bbcode_php
  • (6)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
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (7)postbit
  • (8)postbit_onlinestatus
  • (8)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_postinfo_query
  • fetch_postinfo
  • 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