{"id":4822,"date":"2018-01-08T17:17:37","date_gmt":"2018-01-08T11:47:37","guid":{"rendered":"\/?p=4822"},"modified":"2019-08-21T18:40:35","modified_gmt":"2019-08-21T13:10:35","slug":"adding-custom-asset-metadata-in-aem-cms","status":"publish","type":"post","link":"https:\/\/www.argildx.us\/technology\/adding-custom-asset-metadata-in-aem-cms\/","title":{"rendered":"Adding Custom Asset Metadata in AEM CMS and How to Use It"},"content":{"rendered":"
Working in AEM CMS and need to add custom metadata like tags, dates, or text properties to images and videos? Read this quick how-to from our AEM experts.<\/span><\/p>\n Go to projects page ( http:\/\/<host>:<port>\/projects.html<\/span> )<\/p>\n Select \u2018Tools\u2019 from the right rail and then go to \u2018Assets\u2019 and select \u2018Metadata Schema\u2019.<\/p>\n \u00a0 <\/p>\n Click on add button and provide a name to your schema.<\/p>\n In this case, I have created a schema named \u2018DemoSchema\u2019.<\/p>\n <\/p>\n Select your schema from the list by checking the checkbox and click on edit.<\/p>\n Here you will get an empty form in tab layout with all the widgets present in the right section,\u00a0we can drag and drop widgets to our form.<\/p>\n <\/p>\n Provide a name for your tab from settings and drag widgets onto the form.<\/p>\n Select a widget and go to setting option on the top right.<\/p>\n \u00b7 Provide name to a field using \u2018Field Label\u2019.<\/p>\n \u00b7 In \u2018Map to property\u2019 field give the property path in which you want the value to be stored inside the image file. This property will be automatically created once this field will get authored.<\/p>\n \u00b7 Give placeholder (If required), choose distinct options like required, editable, empty in read-only.<\/p>\n \u00b7 If a field is wrongly placed either drag it to right position or delete it using the delete icon below properties.<\/p>\n After making your schema. Select your schema and click on \u2018Apply to folders icon on the top rail and select the folders on which you want your schema to be applied.<\/p>\n <\/p>\n Properties will look like this:<\/p>\n <\/p>\n To utilize these properties in sightly used in AEM CMS, make a java class using resource API.<\/p>\n In Java, I have injected the image path and then I\u2019ve extracted resource out of it using resource resolver and extracted properties out of it.<\/p>\n Interested in more training and support for your organization using AEM CMS? <\/span>Request a consultation<\/span><\/a> to discuss Argil DX managed services.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":" PROBLEM STATEMENT Working in AEM CMS and need to add custom metadata like tags, dates, or text properties to images and videos? Read this quick how-to from our AEM experts. Step 1: Go to projects page ( http:\/\/<host>:<port>\/projects.html ) Select \u2018Tools\u2019 from the right rail and then go to \u2018Assets\u2019 and select \u2018Metadata Schema\u2019. \u00a0 … Read more<\/a><\/p>\n","protected":false},"author":9,"featured_media":7292,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","content-type":"","footnotes":""},"categories":[66],"tags":[81,65,25,82,83,84,41,85,27,86,87,88,89,90],"yst_prominent_words":[534,2369,2377,1427,1831,2017,1833,2376,1220,2372,2378,2370,837,979,2373,2374,2371,1111,2375,2379],"acf":[],"yoast_head":"\nStep 1:<\/strong><\/h5>\n
Step 2:<\/strong><\/h5>\n
Step 3:<\/strong><\/h5>\n
Step 4:<\/strong><\/h5>\n
Step 5:<\/strong><\/h5>\n
Step 6:<\/strong><\/h5>\n
Step 7:<\/strong><\/h5>\n
@Model(adaptables\u00a0= {\u00a0Resource.class,\u00a0SlingHttpServletRequest.class\u00a0}, cache =\u00a0true)\u00a0\r\n\r\npublic\u00a0class\u00a0ImageMetadataModel\u00a0{\u00a0\r\n\r\n\u00a0\r\n\r\n@Inject\u00a0\r\n\r\n@Optional\u00a0\r\n\r\nprivate\u00a0String\u00a0imagePath;\u00a0\r\n\r\n\u00a0\r\n\r\n@SlingObject\u00a0\r\n\r\nprivate\u00a0ResourceResolver\u00a0resourceResolver;\u00a0\r\n\r\n\u00a0\r\n\r\npublic\u00a0String\u00a0getProperty\u00a0()\u00a0{\u00a0\r\n\r\nResource\u00a0resource\u00a0=\u00a0resourceResolver.getResource(imagePath\u00a0+\u201c\/jcr:content\u201d);\u00a0\r\n\r\nString\u00a0property\u00a0=\u00a0\u201c\u201d;\u00a0\r\n\r\nif\u00a0(resource\u00a0!=\u00a0null) {\u00a0\r\n\r\nValueMap\u00a0valueMap\u00a0=\u00a0resource.getValueMap();\u00a0\r\n\r\nif\u00a0(valueMap.containsKey(\u201cpropertyname\u201d)) {\u00a0\r\n\r\nproperty\u00a0=\u00a0valueMap.get(\u201cpropertyname\u201d,\u00a0String.class);\u00a0\r\n\r\n}\u00a0\r\n\r\n}\u00a0\r\n\r\nreturn\u00a0property;\u00a0\r\n\r\n}\u00a0\r\n\r\n}<\/pre>\n