Add custom metadata fields for DAM assets in a particular folder - metadata

I created custom metadata fields for DAM Assets in CQ 5.6.1 using the steps detailed here. However, as described in the document, these changed fields are available for ALL assets in the DAM.
I need these metadata fields to be made available to only a specific folder, say /content/dam/foo instead of every asset.
How can I achieve this?

In my knowledge, there is no straight forward way to achieve this but there is one trick to handle this.
AEM DAM has the notion of meta schema editors. These editors are tied to asset file type, meaning - jpeg, mov, etc. For an asset MIME type, you can define the meta data and its associated form.
AEM 6.0 provides choral UI interface to achieve this --
http://localhost:4502/libs/dam/gui/content/metadataschemaeditor/schemalist.html/dam/content/schemaeditors/forms
Am not aware of any such interface in AEM 5.6.1. The nodes tied to this are at /libs/dam/content/asseteditors/image/jpeg/formitems. You could overlay them at /apps to add the required metadata.
Coming to the question, the trick is to add the file type into your dam content hierarchy. Example - /content/dam/jpeg/foo, /content/dam/png/foo, etc. This way, you would get different metadata for different folders of the dam.
Adobe recommends this approach as AEM 6.0 introduced the concept of processing profiles which you could attach to folders. This way, your different file types could get different treatments.

Related

AEM 6.4 asset renditions, is it safe to remove all the rendition

I have created a custom workflow model for DAM update asset. I have kept two steps only Metadata Processor and DAM Update Asset Workflow Completed
I am on 6.4 and I could see 319x319 rendition is used in content finder. Want to know if other renditions are used by any default AEM components? If used, is there any possibility to make all of them point to a single rendition?
You can safely remove all renditions, if, in fact, you do not use them at all and you display the raw image from your DAM (the only downside is that your Content Authors will lose several thumbnails, usually helpful to identify the asset they want to use). If you need image manipulation and optimization, you can review ACS Commons Named Transform Image Servlet or any other external service (Akamai, Adobe Dynamic Media).

How to combine authorable css files in css.txt in aem

We have an existing AEM application where there are 100s of pages. On most of the pages, different css files are getting loaded via a separate network call. We need to optimize this. What I am thinking is if we can:
1. Author the list of css files on the page as a page property.
2. In our code, this page property is read and all the css files mentioned as a property value get combined and rendered on the page. Similar to what is done in css.txt file or embed property.
Please suggest.
Their are few ways to reduce the network calls for css files in AEM
1) Add the css files at the template level so that all the css files are loaded once.
2) Instead of adding the category of the clientlibs use the embed property of the clientlibs. AEM will combine all the clientlibs provided in the embed property into a single clientlib and their will be only network call. But the size of the css file may increase after combining and it will effect the page load time for the first time.
But if your requirement is to author the css files then I will suggest you have a dropdown kind of property in your dialog where all your css files are displayed and the author can select the css according to the need. Once selected then you can apply those css to the html by reading through sightly.
So, it seems you don't want to or cannot use the clientlib functioanlity which is an ootb AEM feature.
No matter what solution you choose - maybe a frontend JavaScript snippet that can decide which CSS files would be needed, or some logic that builds CSS includes at render time based on the components used in the page, or something completely different - I would strongly suggest not to put the CSS files to be used in the editor's responsibility.
If they need some additional styles to be set, use the Adobe Style System. But do not abuse page properties for CSS file configurations.
I mean "hundreds of pages" sounds like a rather small site, but it might still increase your maintenance efforts a lot, when the first people start to complain about wrong colors or font sizes...

How to create Content Fragments from JSON descriptions? (AEM 6.3)

I am new to AEM and need a high level understanding of this use case before diving deep into the coding specifics.
I want to programmatically create new Content Fragments using data from external authoring systems.
The content will be supplied as a zip containing both a formatted html version and a JSON file describing the structure (no styling info) plus any media assets referenced in the html/JSON.
Desired AEM functionality:
- unpack zip
- ingest assets to DAM
- create new content fragment from predefined content fragment model
- use JSON structure to complete content fragment (data will be consistent and cf model designed to suit) and reference assets in DAM
Stretch goals:
- create new experience fragments based on the new content fragment (using metadata in JSON?)
- create new draft page placing the content or experience fragment into a component
What is the best way to ingest and automate this content? Research so far suggests a workflow. I am keen to understand the more detail on how this is done and any examples available.
I will be starting with 6.3 so there are no legacy issues.
You can use the contentFragmentManager from the API.
Content Fragment Manager API

Restrict the Type of files to be upload in DAM under a specific Path in AEM 6.3

I want to restrict the types of files to be uploaded under a path. For Ex, /content/dam/test should only upload Pdf's file under it.
I try to add a property mimeTypes under this node :
/libs/dam/gui/content/assets/jcr:content/actions/secondary/create/items/fileupload
but it puts the restrictions over the complete dam folder.
Any Help will be appreciated.
2 options that I can think of:
Do it in JS. Add a listener and write custom logic there.
Add a custom step in upload asset workflow and perform all your logic
there.

What's the best way to use CSV source data in a list component?

Disclaimer: I am not an AEM developer, I'm filling in on a project, so forgive me if I am missing the obvious.
I have a page template that will contain a component that will show a list of locations, this template will be used for many city pages.
I'm trying to figure out the best way to get the content into the JCR or read it using a script from a CSV file.
Are there any out-of-the box or open source components out there that can accomplish this?
There are several ways to accomplish your task. The easy part should be rendering the information. You would usually implement a Sling model or a class extending WCMUse, access the repository via the Sling API and render the resources via Adobe HTL. The resources being rendered have to be selected of course: write a Servlet which provides an interface to the resources and use an adequate form element in the component's dialog.
The hard part consists of two parts:
Perhaps just upload the file, process the data and by using the Sling API for resource creation, you can write the data into the repo. You could also utilise the DAM for such tasks and implement a workflow.
Depending on the amount of data, you might want to save the data as JSON string as property of a node.
I hoped that helped a bit.
"Are there any out-of-the box or open source components out there that can accomplish this?"
Simple answer: NO
While there are several libraries that can help you parse CSV files, storing it in JCR depends completely on your project. The structure can be arbitrary or (in a brute force way) you can just store the CSV file as data in your node but that may not be useful.
Depending on how you plan to use the data, it may be useful and optimal to save it in a relevant hierarchy for your project.