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

Reply
 
Thread Tools
Dynamic Picture Resize for [IMG] tag Details »»
Dynamic Picture Resize for [IMG] tag
Version: 1.0.1, by TECK TECK is offline
Developer Last Online: Nov 2023 Show Printable Version Email this Page

Category: Show Thread Enhancements - Version: 3.6.8 Rating:
Released: 09-06-2007 Last Update: 09-07-2007 Installs: 165
Uses Plugins
Code Changes  
No support by the author.

If an image submited by a user (using the [IMG] bbcode tag) is to big, chances are that it will break your current vBulletin style. This hack will dynamically resize that image to acceptable dimensions, that you previously specified. It will do it for pictures inserted into postbit or user signature.

The code modifications listed below were tested into a clean installed vBulletin board. They work 100%.

Installation
In order to perform an efficient modification of your files, I recommend you to use Komodo Edit or Textpad.
Both editors will allow you to complete all steps without any coding errors.

You will need to make one small change for each of the following files:

? vbulletin_global.js (folder /clientscript)
? class_bbcode.php (folder /includes)


Make sure you modify, save and upload one file at the time to your server.
Then, simply run the product-dynamicpic.xml file.

Once the product installed, don't forget to enable it.
Go to your vBulletin Options, click on Dynamic Picture Resize setting group and set all your options.
If you encounter any problems, feel free to post in the support thread.

Learn how to open the image into a new tab/window.
But you should stop using the target tag, since it will be deprecated soon.
There is a reason why all browsers have now the Shift and CTRL options to open a new tab/window with the link you click on.

Show Your Support

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

Comments
  #112  
Old 12-30-2007, 03:40 PM
Alibass's Avatar
Alibass Alibass is offline
 
Join Date: Mar 2007
Posts: 615
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nice little hack and it works well on 3.7.0 b3 for me also. **Installed**
Reply With Quote
  #113  
Old 12-30-2007, 06:44 PM
gforce75 gforce75 is offline
 
Join Date: Sep 2003
Posts: 192
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Awesome hack. Should be in vb by default.
Reply With Quote
  #114  
Old 12-30-2007, 07:08 PM
gforce75 gforce75 is offline
 
Join Date: Sep 2003
Posts: 192
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmm, it messed up vb. The .js modificatiom made my chatbox stop working. The img sized rework. Just make sure u pay attention to this.
Reply With Quote
  #115  
Old 12-30-2007, 11:54 PM
Alien's Avatar
Alien Alien is offline
 
Join Date: Oct 2001
Posts: 827
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Has this been resolved yet?

Quote:
Originally Posted by mask31
hi Teck, the images are not uploaded into database. like i said i set it to 600 x200 max for images in signatures, using the bbcode tag [img]. and it was running fine before inserting your hack, but now we don't get the error when it's bigger than 600 x 200, it's just resizing it.
so no , images are not uploaded into database.

thanks , i'll wait for your help on this
Reply With Quote
  #116  
Old 01-06-2008, 05:07 AM
CCV_Pinto CCV_Pinto is offline
 
Join Date: Oct 2007
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

teck,

do you know if is easy to modificate your javascript to do enlarge the image inside the post, like this mod:

https://vborg.vbsupport.ru/showthrea...118048&page=49

(see the javascript attached at the mod)

what I want to do is use my mod of your mod (quoted below)

but with this functionality of enlargement

I know that for the javascript work properly it has to:

1. when loading the images, add an "identifier" to each one that exceeds the max width and saving the original width (and it would be good to add the warning like the link above)


2. if the user click on the image, just restore the original size (and changing the warning text)

3. if the user click it again, then resize it again


I think this can be easy.. and it would be less "destructive" than the mod which I posted the link... and I have seen that all javascript is done on that post... and it make exactly what I have said... i just dont know how it manages the identifier of the images..

Quote:
Originally Posted by CCV_Pinto View Post
hi..
great work here..

but I would like to resize the images depending of the user resolution...

i thinked about setting a maximum width like a percentage of the resolution or the width like the resolution - K (where K is a constant that I want configure through admin cp)

i choosed the second option... because its better at my case...

so, I did this modification at vbulletin_global.js

Code:
function resize_image(obj, link, k)
{

    var browserwidth = window.document.body.clientWidth;
    var maxwidth = browserwidth - k; 

	if (obj.width > maxwidth)
	{
		obj.style.cursor = 'pointer';
		obj.style.width = maxwidth + 'px';
		obj.style.height = parseInt(obj.height * maxwidth / obj.width) + 'px';
		obj.onclick = function()
		{
			window.open(link, '_blank');
			return false;
		};
	}
}
I think this will work fine.. i am posting before trying...

but I dont know why I have to modify the CSS... thats for resizing when javascript is disabled?

I will try to make my mod and use it without the CSS mods... then I post here the results... but if someone knows the answer then can help me...

thnks

ps: it worked fine!
but I am curious about what that css will do... i think thats because of javascript desabled.. or that avoid to load the image and then resize it.... but i am not sure...
Reply With Quote
  #117  
Old 01-06-2008, 10:29 AM
ParsianSat_Net ParsianSat_Net is offline
 
Join Date: Sep 2007
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Please
give me screen hosts
Reply With Quote
  #118  
Old 01-13-2008, 01:28 AM
TECK's Avatar
TECK TECK is offline
 
Join Date: Nov 2001
Location: Canada
Posts: 4,182
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Alien View Post
Has this been resolved yet?
See post 108.
Reply With Quote
  #119  
Old 01-14-2008, 10:57 PM
kiennt718 kiennt718 is offline
 
Join Date: Oct 2007
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've tried this mod, thanks TECK, it works well.

But I need some enhancements, pls help !

In my forum, users send a lot of image in posts, and I want the images have better layout:

1. Don't touch the small in-line image like this one
2. For the image that larger than 200 px wide, I would like to have them center-aligned,




so i did some modifications in the code

PHP Code:
$dynimage '';
        if (
$this->registry->options['dynamicpic_enabled'])
        {
            
$dynwidth intval($this->registry->options['dynamicpic_width']) - 1;
            
$dynimage = ($dynwidth 0) ? 'class="resizeimage" onload="resize_image(this, \'' .  $link '\', ' .  $dynwidth ');" ' '';
            list(
$width$height$type$attr) = getimagesize($link);
         }
      if (
$width >200
      {
      
       return 
'<div align="center"><img src="' .  $link '" style="border: 12px solid #EBEBEB" alt="" ' $dynimage '/></div>';
      }
         else
     {
     return 
'<img src="' .  $link '" border="0" alt="" ' $dynimage '/>';
     } 
Live demo at: http://forum.vietpet.com/showthread.php?p=3198#post3198

But here, I used php getimagesize(), which connects to remote server to get actual width of the image. It slows the page load EXTREMELY.

May be CSS can help? But I don't know how to modify CSS

CAN YOU GIVE A SOLUTION?

Thanks a lot in advance

Kien, NT
Reply With Quote
  #120  
Old 01-14-2008, 11:43 PM
Chevy II Chevy II is offline
 
Join Date: Nov 2003
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have one skin that does not resize the images, I made the same changes to all skins. What could the problem be?

Thanks for your assistance!
Reply With Quote
  #121  
Old 01-15-2008, 03:27 AM
kiennt718 kiennt718 is offline
 
Join Date: Oct 2007
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Chevy II View Post
I have one skin that does not resize the images, I made the same changes to all skins. What could the problem be?

Thanks for your assistance!
May be, you install the skin AFTER the mod has been installed? Do import product again, overwrite = YES
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 10:41 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.05260 seconds
  • Memory Usage 2,321KB
  • 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
  • (1)bbcode_code
  • (1)bbcode_php
  • (4)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
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (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