Skip to main content
New Participant
May 27, 2016

Quick check if resource exists in sightly?

  • May 27, 2016
  • 2 replies
  • 6737 views

Is there a quick tag we can use to check if a resource exists using sightly? So we want to display default image if an image at a path doesn't exist

or is there a jstl/sling OOB tags that do that. 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

New Participant
May 27, 2016

Use below code

<img src="${properties.imagePath ? properties.imagePath : '/content/dam/default.jpg' } />

Thanks

smacdonald2008
New Participant
May 27, 2016

See comparisons in this article:

http://blogs.adobe.com/experiencedelivers/experience-management/sightly-intro-part-3-2/

for example - you can check the prop of a node - in this case a title. 

<div data-sly-test="${ properties['jcr:title'].length > 3 }">Title is longer than 3</div>

Of course - you can always use Java with a Sightly component and check AEM resources via Java

Hope this helps