[opencms-dev] Question about scaling images...

John Bieling info at jobisoft.de
Wed Sep 13 17:44:31 CEST 2006


I am using OpenCms 6.2.2.

Before the scale-function was implemented in opencms, I mostly uploaded 
images in two sizes, so that i had a thumb and and a big picture I can 
use. I did this, because I think it is bad style to shrink an image by 
html- or css-width/height settings but actually sending a large image.

However, the build-in-editor of opencms does not generate the 
scale-parameter, if an image is scaled "by hand". Thats why i made up 
this workaround, because I did not find anything usefull in the 
mailing-list.:

In my jsp-template I replaced the

<cms:include element="body"></cms:include>

by

<%= JobisoftImgScaler.getContentWithScaledImages(cms, cmsObject, 
cms.getRequestContext().getUri(), "body") %>

which reads the "body"-content of the current file and searches for 
"<img"-tags. Out of each img-tag the html/css-width and -height-settings 
are extracted and compared with the original-images size 
(image.size-property) and if the image is shrinked by more than 10% the 
img tag is replaced by the tag generated by cms.img(). I actually change 
the html generated by the opencms-editor.

This works well, but it looks like a "bad hack" to me and could slow my 
pages down (even though the loading time of the images is speed up a 
lot). Is there any better way for doing that?

Thanks
John Bieling





More information about the opencms-dev mailing list