Re: [Templates] Image plugin
[prev]
[thread]
[next]
[Date index for 2005/02/08]
Perrin Harkins wrote:
> On Mon, 2005-02-07 at 19:20 +0100, Tosh Cooey wrote:
>
>>I'm not a fan of the server having to determine the size of an image file, but
>>my designer is a bit of a standards fanatic and pefectionfascist and wants
>>height and width tags for the images.
>
>
> This has changed over time, but it used to be that browsers would not
> display your page at all until the images were downloaded if you were
> missing any height and width tags. Now they mostly go ahead and adjust
> later.
There are still advantages to adding the height and width. As soon as a
browser gets them it can allocate that amount of space and start
formatting everything else around it. As you have mentioned they will
start displaying text immediately which which can lead text jumping
about a bit. If the size of the image is present its a much smoother
operation on the eye.
As far as standards are concerned this is from XHTML strict so the
height and width are not required just good practice ;)
<!--=================== Images ===================-->
<!--
To avoid accessibility problems for people who aren't
able to see the image, you should provide a text
description using the alt and longdesc attributes.
In addition, avoid the use of server-side image maps.
Note that in this DTD there is no name attribute. That
is only available in the transitional and frameset DTD.
-->
<!ELEMENT img EMPTY>
<!ATTLIST img
%attrs;
src %URI; #REQUIRED
alt %Text; #REQUIRED
longdesc %URI; #IMPLIED
height %Length; #IMPLIED
width %Length; #IMPLIED
usemap %URI; #IMPLIED
ismap (ismap) #IMPLIED
>
If it was me I would try the page without them and see how it loads and
if its fine then I wouldn't worry about it (try at different speeds). I
take it you have no idea what image is going to be loaded so you need to
calculate the image sizes. If the images are all under a certain size
(quite small) then the designer should be able to wrap them in a div to
avoid jumping text, this assumes a reasonable size otherwise you are
back to recalculating sizes for the div.
If sizes are a must another alternative would be to pre-calc all the
image sizes and stick them in a hash and serialize it to disk somewhere
assuming there are not thousands of them this would be fine. If there
are millions of the blighter's then run a batch script over then and
dump the sizes into a database. Both methods might give you zero benefit
if the module you use to calc the image size is written in XS or uses
some other fancy jiggery pokery to get the image dimensions.
Try
use Image::Size;
my ($x, $y) = html_imgsize("something.gif");
and see how it performs.
_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates