I am trying to implement the image metadata inside the module with the following code.
<sly data-sly-use.myImg="${properties.laptopReference}/jcr:content/metadata">
<img src="${properties.laptopReference}" class="cover lazyloaded" alt="${myImg.valueMap['dc:title']}">
</sly>
It is working, but if the image is not there it is giving 500 page error.
Any idea to resolve this error?
Solved! Go to Solution.
Views
Replies
Total Likes
Finally, I resolved the issue. I wrote a if condition to check and print the image metadata and it was working good. Thanks for helping out guys.
Hi @Ameen_Dev,
You can verify if the image is there using the data-sly-test.
<sly data-sly-test="${properties.laptopReference}"
data-sly-use.myImg="${properties.laptopReference}/jcr:content/metadata">
<img src="${properties.laptopReference}" class="cover lazyloaded"
alt="${myImg.valueMap['dc:title']}">
</sly>
You can first check if laptopReference exist or not, use data-sly-test to validate, if true then execute your logic.
<sly data-sly-test="${properties.laptopReference}"
data-sly-use.myImg="${properties.laptopReference}/jcr:content/metadata">
<!-- add your logic--------->
//if true then your logic will work otherwise it will not
<img src="${properties.laptopReference}" class="cover lazyloaded"
alt="${myImg.valueMap['dc:title']}">
</sly>
I already tried that. even after adding the test condition it was not working. It seems like, it is looking for the metadata properties which are not filled up.
Finally, I resolved the issue. I wrote a if condition to check and print the image metadata and it was working good. Thanks for helping out guys.