Posted on 2 Comments

Image Scaling in Liferay

Liferay Logo

Have you ever wondered if Liferay offer image scaling out of the box? Yes it does, you only need to enable this option!

In portal-ext.properties add:

image.auto.scale=true
image.hook.impl=com.liferay.portal.image.DLHook

The second property image.hook.impl sets the hook implementation to be used to trigger automatic data migration during an upgrade.

Requesting Scaled Images

Now in order to request scaled images simply use height and width as GET parameters, like so:

http://localhost:8080/image/journal/article?img_id=x&height=y&width=z

Caching

For performance reasons Liferay caches scaled images. Please refer to ImageUtil API for more information.

Further Readings

Further information can be obtained by consulting the Image section in the Liferay Portal 6.1 – User Guide.