When the images' size is specified in the <img> XHTML elements, the
pages are rendered faster because the browser knows in advance how
much space to reserve. It's a good usability practice too. So, I
wanted BoltWire to put the images' size automatically. Here you are my
solution:
This is line 678 of barn/scripts/markups.php:
return BOLTescape("<img src='$fieldURL$location' $attr />");
The following four lines are needed instead:
list($realwidth,$realheight) = getimagesize($fieldURL.$location);
$realwidth = strpos($attrs,'width=') ? '' : " width='$realwidth'";
$realheight = substr($attrs,'height=') ? '' : " height='$realheight'";
return BOLTescape("<img src='$fieldURL$location' $attr$realwidth
$realheight$alt />");
Then the real width and height will be added to the <img> only when
they have not been specified by the editor.
There are two little problems:
1) The strpos functions could match "width=" and "height=" inside a
title attribute... Probably no-one will have an image title with the
text "width=" in it, but who knows. A better check would be needed to
prevent that strange and unlikely case, using a regular expression.
2) The change is not fully backward compatible. With the current
system, when the editor specifies only the height or only the width,
it seems the other dimension is calculated by the browser keeping the
original proportions (I don't know if it's a convention or a XHTML
rule). With the proposed change, when the user specifies only one
dimension, the other one is the real one. I think nobody designs
special layouts by specifing only one image dimension [:-)].
I think both problems are unlikely to bother and the first one is easy
to solve if wanted.
Automatically include the images' size is very important, so I think
this improvement could be considered for inclusion in the next
version, maybe with a solution to problem 1.
I'm using this new feature with an alternative markup {{ file | label
| attrs }} I'm experimenting with (using a rewritten markup function),
but I've tested it with the original [^ ^] markup and the original
BOLTMuploads function too.
Cheers,
Marcos
--
http://alinome.net
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"BoltWire" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/boltwire?hl=en
-~----------~----~----~----~------~----~------~--~---