liferayliferay-6velocityfreemarkerliferay-velocity

Liferay Web Content Template : How to find out if image has been set?


I have created a Liferay Web Content Structure and Template. This Structure contains an image that can or can not be set. If the image is not set then I do not want to render an IMG tag.

How can I determine in my template if the picture is set / present ?

Best regards,

Daniel


Solution

  • If your field is called imageField you can do it like this with Velocity:

    #if ($imageField.data != "")
      <img src="$imageField.data">
    #end
    

    (For Freemarker you can do a similar test)