Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

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

Avatar

Administrator

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.



Kautuk Sahni
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

0 Replies