Image Components
Resource Captions
When you read about images, accessibility, and media, you will gets miles of ink spilled over the importance of the alt attribute and it's ability to provide a description of the media for those who will not be able to see it. Now I am solid supporter of web standards and a true believer in accessibility, so I'm not taking issue with the alt attribute. But what if you want to describe a picture for people who will see it!
The alt attribute is only used if we cannot access an image or if we mouse over an image and wait for a tool tip to appear. In contrast, it's not just normal, it's required for all images in print media to take a caption, if only a by-line for the photographer or a copyright notice crediting the image's owner. Resource captions is an OO - CSS component for providing captions for images (and other media as well) on your webpages. The caption should generally be shorter than the width of the image; I've used smaller images to show how the captions push out to the right when they get too long.
Component CSS
.insertPrimaryResource {
float: left;
}
.insertSecondaryResource {
float: right;
}
.resourceCaption {
display: block;
margin: -2em 0.5em 0 0.5em;
font-size: 0.8em;
text-indent: 1em;
}
Component XHTML
<div id="parentContainer">
<div class="insertPrimaryResource">
<img src="../Images/TopLeftCorner6.jpg" height="100" width="100" alt="The proposed top left corner image for the fluid image border." />
<em class="resourceCaption">Top Left Corner</em>
</div>
<p>
Here's a lot of content...
</p>
<div class="insertSecondaryResource">
<img src="../Images/Logo4.jpg" height="150" width="150" alt="The proposed logo image to be used for the page." />
<em class="resourceCaption">Logo Image for the site.</em>
</div>
<p>
Here's a lot of content...
</p>
<div class="spacer"></div>
</div>
Fluid Border: Top Left Corner
Here's a lot of content directly discussing the top left corner image as it relates to the fluid image border. Here's a lot of content directly discussing the top left corner image as it relates to the fluid image border. Here's a lot of content directly discussing the top left corner image as it relates to the fluid image border. Here's a lot of content directly discussing the top left corner image as it relates to the fluid image border.
Logo Image for the site.
Here's a lot of content discussing the top left corner some more, but there's also a brief mention of the logo image too. Here's a lot of content discussing the top left corner some more, but there's also a brief mention of the logo image too. Here's a lot of content discussing the top left corner some more, but there's also a brief mention of the logo image too. Here's a lot of content discussing the top left corner some more, but there's also a brief mention of the logo image too.
Wrapping Resource Captions
That's an excellent technique for short captions, but what if you just can't settle for that. Sometimes you just need write the content that you need to write. This is a bit trickier because there are number of older browsers which make our lives extremely difficult. If you do not want to have to cope with this complexity and can live tailoring your captions so they fit the size of the image, then the previous method definitely works best at the present time.
However, if you need wrapping captions and / or you're willing to write a little extra code for IE6 & 7, then you can start with the previous component and add the following touches. Note: the XHTML template is identical to the original resource caption component; you simply have the option to write as much text as you want.
Component CSS
.insertPrimaryResource,
.insertSecondaryResource {
display: table;
width: 1px;
}
For most major browsers, this causes the div element around the image to snap to the width of the image, but it forces the text to wrap when it hits the edge of the div. Exactly what we want. However, for IE 6 and 7, it causes the words of our long caption to stack up in a huge column of words (one word per line), creating a truly ludicrous effect. Therefore, we need to add an IE7 and below stylesheet to make some adjustments. Here's the CSS for the IE7 and below stylesheet. Special thanks to forum buddies and CSS gurus, Rayzur and Paul O'B of Sitepoint, for adding word wrapping for this component.
.insertPrimaryResource,
.insertSecondaryResource {
width: auto;
}
.resourceCaption {
width: 150px;
width: expression(this.parentNode.offsetWidth-22);
}
Fluid Border: Top left corner image of the piece of parchment.
Here's a lot of content directly discussing the top left corner image as it relates to the fluid image border. Here's a lot of content directly discussing the top left corner image as it relates to the fluid image border. Here's a lot of content directly discussing the top left corner image as it relates to the fluid image border. Here's a lot of content directly discussing the top left corner image as it relates to the fluid image border.
The official logo image for the Earth Chronicle website, created by chroniclemaster1.
Here's a lot of content discussing the top left corner some more, but there's also a brief mention of the logo image too. Here's a lot of content discussing the top left corner some more, but there's also a brief mention of the logo image too. Here's a lot of content discussing the top left corner some more, but there's also a brief mention of the logo image too. Here's a lot of content discussing the top left corner some more, but there's also a brief mention of the logo image too.
Thumbnail List
Thumbnail images are a common organizational challenge. This component neatly organizes a list of thumbnails with descriptive text. The XHTML you write to trigger it is pretty simple, and it's completely regular making it easy to generate from a server side application for image indexes, photo albums, etc.
Component CSS
/* Thumbnail List */
#thumbnailList,
.thumbnailList {
list-style-type: none;
clear: both;
}
#thumbnailList img,
.thumbnailList img {
float: left;
margin: 0 0.2em 0.2em 0;
border: 0.1em solid #000000;
}
#thumbnailList li,
.thumbnailList li {
clear: both;
margin-bottom: 2em;
}
#thumbnailList a,
.thumbnailList a {
font-weight: bold;
}
Component XHTML
<ul id="thumbnailList">
<li>
<a href="AfricaWMGP.aspx">
<img src="../Images/AfricaWMGPThumb.jpg" height="50" width="45" alt="SRTM data set of Africa." />
Africa</a> - This image shows an SRTM data set for the continent of Africa.
</li>
<li>
<a href="AfricaSRTM-Water.aspx">
<img src="../Images/AfricaSRTM-WaterThumb.jpg" height="50" width="46" alt="SRTM data set of Africa with bodies of water added." />
Africa (with water)</a> - This image shows an SRTM data set for the continent of Africa. It includes water, ie lakes rivers, etc.
</li>
.
.
.
</ul>