ChristianBlog.Com Home About Register Login Join For Free

Forcing Image Resizing

One of the big items on our "To Do List" has been a way to solve images from breaking our website.

Because we have a fixed-width website design - at the moment - it is fairly easy to break the layout of the page by posting an image that is larger then what our fixed width design is setup for.

What happens is the main table with all the Blog text pushes out to the right-side of the page -- not good!

So we had a number of options before us:

  1. Force people to use our own website for storing images (not something we want to do).
  2. Resize images on-the-fly (but causes long load times).
  3. Find a way via JavaScript or CSS to resize them.

Our entire development team spent the better part of this afternoon trying to find a viable solution to this issue.

Eventually one of us came across a blog entitled Max-Width and Faking it for IE which explains a way to to CSS to force a max-width of an object.

As the author correctly notes, "it's best to size an image accordingly", but in our situation that just was not possible.

Thankfully he provided to us the first solution that seems to be working in both Internet Explorer and FireFox under Windows.

We have not tested it under Mac, Linux, or other OS's, nor any browsers other then IE and FireFox, but would welcome some feedback if you happen to use something other then what we've tested it under!

As the author of the article explains, IE just does not support the CSS max-width feature, which is why he suggested using in-line Javascript within your CSS file using the syntax:


selector {width: this.width > value ? value: true);}


Rather ingenious, eh!


Because we already have a CSS function that get's assigned to all BBCode Images it was just a matter of adding to more lines, and bam, now it seems to be working!


.ImageBBCode
{
text-align: left;
vertical-align: text-top;
margin-top: 10px;
margin-bottom: 10px;
border: 1px solid #333;
max-width: 500px;
width: this.width > 500 ? 500: true);
}



Because any images over the size of 500 (or there-about) cause the fixed-design website to explode, we simply set the max-value at 500 pixels and we are good to go! (hopefully!!)

A great little designing time and thanks to the person over at http://phydeaux3.blogspot.com/ for taking the time to blog about this!

posted: 02/07/2006 03:01pm by christianblog
View: Backlinks, Permalink
Total Views: 3854
ShortURL: http://christianblog.com/7665
Category: Internet / Technology
Print This Blog Entry
Blog Tags: cssfirefoxinternet explorerjavascriptmaxwidthphydeaux3
Share: Share Via Email  Share On Twitter.Com  Share On Facebook.Com  Share On Digg.Com  Share On Digg.Com  Post To Evernote  Share On StumbleUpon.Com  Share On Propeller.Com  Share On Technorati.Com  Share On FriendFeed.Com  Share On Reddit.Com 
 

Author Details:

Author: christianblog
Location: Eureka California USA
Gender: Male
Age: 36
Blog Entries: 88 (archive)
Blog Comments: 16

My Biography:

this is an account for the christianblog.com group to be able to relay information about christianblog.com to the general public - typically news and updates about christianblog.com!...... view full biography

My Recent Blogs:

New Feature: Attach Photo...
New Feature: "My Wal...
Yearly Pledge Partner Pri...
New Advertiser: MindEquip...
Suggestion Featured Syste...
New Payment Method: Alert...
New Features For Pledge M...
Attach A Blog Photograph!...
Premier Membership Become...
Update To Prayer Request ...


Thanks to my good friend Eric Coleman of http://aplosmedia.com for testing out this new method using both FireFox and Safari under the Mac OS!! He reports it works in both.

  Posted 02/07/2006 05:28pm
Author: support

In order to respond to this blog you must be a registered member and logged into the ChristianBlog.Com website.


Information:
Terms of Service
Content Policy
Privacy Policy
DMCA
Resources:
About ChristianBlog.Com
Advertising
RSS Feeds
Premier Membership
Sponsors:
LongMessage.Com
Assembly of God Jobs Online
Lamsa Bible Online
Logos Bible Software