Get the Asset meta data from the asset node in AEM | AEM Community Blog Seeding | Community
Skip to main content
kautuk_sahni
Community Manager
Community Manager
July 15, 2021

Get the Asset meta data from the asset node in AEM | AEM Community Blog Seeding

  • July 15, 2021
  • 0 replies
  • 1308 views

BlogImage.jpg

Get the Asset meta data from the asset node in AEM by keshav chaurasiya

Abstract

Get the Assets meta data from the asset node in AEM sling model

@Model(adaptables = {SlingHttpServletRequest.class,Resource.class}, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL, resourceType="myproject/components/content/image")

@Exporter(name="jackson", extensions="json", options= {

@ExporterOption(name = "MapperFeature.SORT_PROPERTIES_ALPHABETICALLY", value = "true")

})

public class ImageModel{

private static Logger LOG = LoggerFactory.getLogger(ImageModel.class);

@SlingObject

private SlingHttpServletRequest request;

@Inject

@Via("resource")

private String image;

}

@Inject

@Via("resource")

private String imageMetaData;

/**

* @return the imageMetaData

*/

public String getImageMetaData() {

String url = request.getRequestURI();

Resource resource = request.getResourceResolver().getResource("/content/dam/my-project/image/image.png");

Asset asset = resource.adaptTo(Asset.class);

String width = asset.getMetadataValue("tiff:ImageWidth");

return this.imageMetaData;

}

}

Read Full Blog

Get the Asset meta data from the asset node in AEM

Q&A

Please use this thread to ask the related questions.

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