Image Metadata causing 500 error | Community
Skip to main content
Level 4
December 28, 2023
Solved

Image Metadata causing 500 error

  • December 28, 2023
  • 3 replies
  • 955 views

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?

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

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.

3 replies

Mahedi_Sabuj
Community Advisor
Community Advisor
December 28, 2023

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>

 

Mahedi Sabuj
HeenaMadan
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
December 28, 2023

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>

 

Ameen_DevAuthor
Level 4
December 29, 2023

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.

Ameen_DevAuthorAccepted solution
Level 4
December 29, 2023

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.