Displaying Metadata values from a File Content Type


When a new file is uploaded dotCMS extracts its metadata and indexes it for searches or to be displayed.

This sample shows how to take a list of file content types and display their metadata key values.


${esc.h}foreach(${esc.d}con in ${esc.d}dotcontent.pull("+structureName:FileAsset",2,"modDate desc"))
File: ${esc.d}con.title
MetaData: ${esc.d}con.metaData
${esc.h}${esc.h}Loop through all metadata field key, values
${esc.h}foreach(${esc.d}md in ${esc.d}con.metaData.entrySet())
${esc.d}md.key : ${esc.d}md.value
${esc.h}${esc.h}Print each value separately:
Content type: ${esc.d}con.metaData.contentType
File Size: ${esc.d}con.metaData.fileSize

Have you created code you'd like to share with the dotCMS community?

Share your code Become a Contributor