Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Quick check if resource exists in sightly?

chetanvajre2014
Level 5
Level 5

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. 

0 Replies
smacdonald2008
Level 10
Level 10

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

demou42921580
Level 1
Level 1

Use below code

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

Thanks