/*$Id: image_caption.js,v 1.1 2008/02/23 06:24:07 davidwhthomas Exp $*/ $(document).ready(function(){ $("img.caption").each(function(i) { if ($(this).width()) { // This image has a width and is ready to go process_image(this); } else { // This image has a width of zero and may not be completely loaded, // so we'll wait for the load event $(this).load(function(){ process_image(this); }); } }); }); function process_image(img) { var imgwidth = $(img).width(); var imgheight = $(img).height(); var captiontext = $(img).attr('title'); var alignment = $(img).attr('align'); // Do not display a caption if the title attribute is blank if (captiontext) { $(img).attr({align:""}); // Add an alignment class to the container so we can style margins and padding if (alignment == 'left' || alignment == 'right') { $(img).wrap("
"); $(img).parent().addClass('float_' + alignment); } else { $(img).wrap(""); } $(img).parent().width(imgwidth); $(img).parent().append("