888888.888888.88""Yb..dP"Yb..8888b..Yb..dP.88b.88....db....8b....d8.88..dP""b8..dP"Y8
88__...88__...88__dP.dP...Yb..8I..Yb.YbdP..88Yb88...dPYb...88b..d88.88.dP...`".`Ybo."
88""...88""...88"Yb..Yb...dP..8I..dY..8P...88.Y88..dP__Yb..88YbdP88.88.Yb......o.`Y8b
88.....888888.88..Yb..YbodP..8888Y"..dP....88..Y8.dP""""Yb.88.YY.88.88..YboodP.8bodP'


88b.88.888888.888888.Yb........dP.dP"Yb..88""Yb.88..dP
88Yb88.88__.....88....Yb..db..dP.dP...Yb.88__dP.88odP.
88.Y88.88"".....88.....YbdPYbdP..Yb...dP.88"Yb..88"Yb.
88..Y8.888888...88......YP..YP....YbodP..88..Yb.88..Yb

February 27, 2010

Themery Blogged Title

This is the ninth post in my series, Themery : Blogged, where I blog about each step of a WordPress theme design.

This theme, as I explained in previous posts, is elastic, meaning that as you increase the text size, the rest of the site scales up accordingly. The problem with this is images, when images scale up on a webpage all kinds of evil ensues and so it can’t really be done. This is my solution.

I will start with some screenshots to demonstrate the end result, then explain what I have done. They aren’t small but I wanted to get across the scale of the problem.

This is the same page at the original font size, and several sizes larger. The bottom image is simply styled with a width in EMs, the image above uses my technique.

Image Screenshot 1 - Default font size
Image Screenshot 2 - 3 times size

Now, before I explain what I have done I wanted to temper expectations a little. This isn’t the grand solution to all image sizing, you might even consider it a slightly hacky solution to the problem, but it does work.

The short version is simply that the top image is actually 5 images, each at intermediate steps, 150px, 180px, 225px. 300px. and finally 450px. Using a div and absolute positioning each image comes into view as the appropriately sized text is selected.

The CSS is split between the stylesheet and inline styles. If you know what sizes your images will be before hand there is no reason why it can’t all be in the stylesheet.

The stylesheet contains two rules:

div.multiimage
{
overflow:hidden;
position:relative;
}

div.multiimage div.subimage
{
margin-top:-1000em;
position:absolute;
}

And the html looks like this:

<!– The Wrapper –>
<div style=”width:15em; height:10em;”>
<!– The original Image –>
<img src=”http://localhost:8080/wp-content/uploads/2008/03/11.jpg” alt=”Williams Formula 1 Car”  />
<!– Larger Image 1 –>
<div style=”width:18em; height:18em; top:12000px; background-image:url(http://localhost:8080/wp-content/uploads/2008/03/21.jpg);”></div>
<!– Larger Image 2 –>
<div style=”width:22.5em; height:22.5em; top:15000px; background-image:url(http://localhost:8080/wp-content/uploads/2008/03/31.jpg);”></div>
<!– Larger Image 3 –>
<div style=”width:30em; height:30em; top:20000px; background-image:url(http://localhost:8080/wp-content/uploads/2008/03/4.jpg);”></div>
<!– Larger Image 4 –>
<div style=”width:45em; height:45em; top:30000px; background-image:url(http://localhost:8080/wp-content/uploads/2008/03/5.jpg);”></div>
</div>

As the text is resized the negative margin (-1000em) of the larger images increases until it reaches a measure equal to the absolute position top, which is 1000 times the size that the base font (the font that applies to the body) will be when we want that image displayed, but in pixels so that it doesn’t change when the font is resized.

In this example the base font size, or 1em, is equal to 10px. So for the first larger image is positioned 12000 pixels from the top. When the font is increased to 1.2 the negative margin then equals 1000 times, i.e. -12000 and the image is displayed.

I have used div tags with backgrounds instead of images so that screenreaders do not end up listing image after image, this after all purely visual.

Disclaimer: As Safari won’t run on my computer I don’t know how it deals with resizing. Firefox on Windows resizes text as:1 , 1.2 , 1.5 , 2 , 3 and it is this I have based this on. Both Opera and IE zoom instead of resizing and so the technique is never used. If someone does try it on a Mac please report back.

Adding Settings To Admin Pages
Wordpress addsettingsfield?
3 comments
page 793
Updating Code Snippets Here
Fun wordpress plugins?
no comment
page 1338
Html 5 Gallery
Html5 image gallery?
6 comments
page 1305
How To Add Sidebars To A Theme
How to register two sidebars in wp?
10 comments
page 1053
Post Image The Easy Peasy Way
Wordpress theimage?
26 comments
page 1065
Using Wordpress As A Php Framework
Php framework wordpress?
2 comments
page 335
Using Your Own Url Shortener
Short url?
4 comments
page 1190
Wordpress Vs Graffiti
Html5 cms?
8 comments
page 95
Post Image The Easy Peasy Way
Wordpress medium size image link?
26 comments
page 1065
Html 5 Gallery
Html 5 gallery?
6 comments
page 1305
Quick N Dirty Admin Login Screen
Web templte admin login page?
no comment
page 128
Post Image The Easy Peasy Way
Wp get url functions?
26 comments
page 1065
Html 5 Gallery
Wordpress html5 theme?
6 comments
page 1305
Wordpress Chat
Wordpress chat?
3 comments
page 1308
Html 5 Gallery
Wordpress html5?
6 comments
page 1305
Post Image The Easy Peasy Way
Wordpress get first image attached to post?
26 comments
page 1065
Html 5 Gallery
Wordpress html5?
6 comments
page 1305
Post Image The Easy Peasy Way
Wp automatically insert image based on tags?
26 comments
page 1065
What Wordpress Workflow Needs
Word press workflow?
3 comments
page 1226
Quick N Dirty Admin Login Screen
Login screen css?
no comment
page 128
How To Add Sidebars To A Theme
Wordpress thematic modify sidebars?
10 comments
page 1053
Six Million Ways To Die Choose One
Ways to die without noticing?
14 comments
page 1128
Post Image The Easy Peasy Way
Wordpress theimage?
26 comments
page 1065
Photoshop Design Framework
Photoshop framework?
3 comments
page 296
Creating Custom Urls
Custom url for wordpress page?
6 comments
page 80
How To Add Sidebars To A Theme
How to add a sidebar to a theme?
10 comments
page 1053
Using Your Own Url Shortener
Htaccess tiny url shortner?
4 comments
page 1190
Photoshop Design Framework
Framework in photoshop?
3 comments
page 296
What Wordpress Workflow Needs
Wordpress workflow?
3 comments
page 1226
Html 5 Gallery
Wordpress html5?
6 comments
page 1305
Using Your Own Url Shortener
Build your own url shortener?
4 comments
page 1190
My Experience Of Flexx
Cant upload image to flexx wordpress theme?
4 comments
page 1026
Post Image The Easy Peasy Way
Wpget post image?
26 comments
page 1065
  1 query every 1555 seconds, updated 1 seconds ago.
Post a comment?