[pmwiki-users] RFC CSS/Pmwiki question

Hans design at softflow.co.uk
Sat Apr 8 11:13:50 CDT 2006


Saturday, April 8, 2006, 2:42:29 AM, Adam wrote:
> Question: How to display an image so that it always renders to an
> exact English/Metric specification in Pmwiki regardless of what it’s
> being viewed on? 
> (for example, an inch or a centimeter)

Interesting question! It is possible, but not necessarily straight
forward. Let me explain in detail:
You can set width and/or height for an image via wiki styles like

%width=100px height=150px%Attach:myimage.jpg

but this way you are restricted to use pixel width and height.
The width and height becomes part of the <img ...> tag.

You can define specific wiki styles for specific widths and heights
in config.php.

For instance you could define (define as many styles as different
measurements are needed):

$WikiStyle['x5cm']['width'] = '5cm';
$WikiStyle['x5cm']['apply'] = 'item';

$WikiStyle['x10cm']['width'] = '10cm';
$WikiStyle['x10cm']['apply'] = 'item';

$WikiStyle['x15cm']['width'] = '15cm';
$WikiStyle['x15cm']['apply'] = 'item';

$WikiStyle['y5cm']['height'] = '5cm';
$WikiStyle['y5cm']['apply'] = 'item';

$WikiStyle['y10cm']['height'] = '10cm';
$WikiStyle['y10cm']['apply'] = 'item';

$WikiStyle['y15cm']['height'] = '15cm';
$WikiStyle['y15cm']['apply'] = 'item';

Each style definition needs ['apply'] = 'item'
so it will be applied inside the img tag.
Otherwise it would be applied to a <span> element around the <img ... >
element, which does not work for sizing the image.

With the above styles defined you can use in a wiki page markup like

%x5cm%Attach:myimage.jpg results in 5cm wide image
%y10cm%Attach:myimage.jpg results in 10cm high image
%x15cm y15cm%Attach:myimage.jpg results in 15cm wide and high image

An interesting variation on this method is using "em" units instead of
cm or other fixed width units. That way the image becomes
proportionally scalable with the font size. Images will grow along
with the text when a user increases the browser's text size.
This is may be very valuable for visually impaired users who increase
the text size to make it readable, as well as for image text effects
like drop-down capital images.



Best,
 Hans                           





More information about the pmwiki-users mailing list