vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Design and Graphics Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=168)
-   -   Resizing only large images, not small ones. (https://vborg.vbsupport.ru/showthread.php?t=131609)

johnstires 11-15-2006 12:37 AM

Resizing only large images, not small ones.
 
I have an html question about resizing an image. How do you resize an image only if it's too big.

For instance if I have an image that is 500px wide and I want to down size it to 450px wide I can write something like this:

Code:

<embed src="$filename"


width=450>
</embed>

However if I have an image come in at 200px I do not want it resized to 450px.

How would I write it so that only images over 450px would get resized but images under 450px would stay the same.


Thanks in advanced!

CyberAlien 11-15-2006 03:03 PM

<img src="blah" onload="if(this.width > 450) {this.width=450;}" />

johnstires 11-15-2006 08:17 PM

This works alot better, Thanks! Is there a way to write it so that I do not see the image resize when the page loads? The embed tag I used did not do that, but the image one I use does.


Code:

<div align="center">

<img src="$filename" onload="if(this.width > 450) {this.width=450;}" />


</img>

</div>


CyberAlien 11-15-2006 08:24 PM

Try this:

<img src="$filename" onload="if(this.width > 450) {this.width=450;} this.style='';" style="display:none;" />

johnstires 11-17-2006 08:23 PM

The image doesn't load at all with that code.

CyberAlien 11-17-2006 08:30 PM

Maybe try to put it in div with size 1x1 and overflow:hidden and when image loads resize that div to image size?

johnstires 11-18-2006 01:48 AM

I'm sorry, my coding skills aren't that good. I'm not really sure what you are describing.


All times are GMT. The time now is 07:30 AM.

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.01039 seconds
  • Memory Usage 1,717KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete