Title: Bericht
Hi,
 
Recently we implemented some functionality that retrieves the width and height of images in mmbase. Although other solutions may already exist we thought this might be interesting to some of you.
 
In order to retrieve these properties from an image we've used ImageInfo, a freely available java class, downloadable at: http://www.geocities.com/marcoschmidt.geo/image-info.html. Imageinfo is used by the added ImageBuilder class, which introduces to new virtual fields to an image node, width and height. This class has to be defined in the image builder configuration file like this:
<classfile>nl.kennisnet.cpb.cloud.builders.ImageBuilder</classfile>
 
As an example of how this could be used, consider a neatly fitting image popup without whitespace around the image. The jsp code looks something like this:
<mm:node number='<%=imageNumber%>'>
<a href="" target="_blank">
</mm:node>
 
Where NewWindow is a small _javascript_ function that creates the popup with the proper width and height.
 
Using these extra virtual fields one can also size an image using the width and height attributes within the HTML image tag, provided that no scaling is taking place using a template attribute. The advantage of this is that the pagelayout remains fixed when the page is being loaded by a browser over a slow connection. Now, images only take the correct space after they have been loaded completely. (Sometimes this is regarded as an undesirable phenomenon)
 
Robin van Meteren
Kennisnet
 

Attachment: ImageBuilder.java
Description: ImageBuilder.java

Reply via email to