Media Upload Template#
The media upload template provides a structured approach to uploading and describing media files within the CMS. This chapter guides you through creating an upload template for a media category in imperia.
Configuring the Media Category#
Configuring a media category involves setting up the appropriate upload template to define the input fields and options available during the media upload process. The upload template acts as a blueprint for capturing relevant information about the media files being uploaded.
To facilitate the configuration process, imperia provides sample templates that serve as references. These sample templates, located in the site/sample/templates directory, offer different levels of complexity: upload-minimal.htms, upload-advanced.htms, and upload-expert.htms. Developers can use these templates as starting points and customize them to meet the specific requirements of their media categories.
Structure of the Upload Template#
Starting from imperia version 11.4 and newer, the structure of the upload template has been updated to simplify the template creation process. Previously, the template required explicit markers, such as <!--upload_start--> and <!--upload_end-->, to define the upload field. However, these markers are no longer necessary.
A minimal upload template in imperia consists of HTML markup and the desired input fields to facilitate the media upload process. Let's take a closer look at the example:
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dateien hochladen</title>
</head>
<body>
<!--template-description:Upload Minimal-->
<!--formstart-->
<?imperia asset_data
name: title
label: Titel
source: *:headline,*:title,*:objectname
hint: Unter diesem Titel finden Sie die Datei im CMS wieder
?>
<!--formend-->
</body>
</html>
In this example, the upload template focuses on capturing the title of the uploaded file. Let's examine the parameters used in the <?imperia asset_data ?> processing instruction:
-
name: title: This parameter specifies the name of the meta-info variable where the entered value will be stored. In this case, the entered title will be stored in thetitlevariable. -
label: Titel: This parameter defines the label or description of the input field. It provides a meaningful representation to guide the user in entering the title. -
source: *:headline,*:title,*:objectname: This parameter specifies the source of the metadata list to be retrieved and made available to the input field. The asterisk (*) denotes all available metadata formats, allowing the template to search for the title in various fields such as headline, title, and object name. -
hint: Unter diesem Titel finden Sie die Datei im CMS wieder: This parameter provides a hint or additional information related to the input field. It gives the user guidance on how the entered title will be used and its significance within the CMS.
Describing Media Content#
Properly describing media content is a crucial aspect of content management. Well-labeled media content contributes to accessibility and search engine optimization. Legal requirements, such as copyright notices, are essential for proper annotation of media content. Many media formats have established metadata formats, such as EXIF, XMP, or IPTC, for capturing metadata. When using images from an image agency, they often already contain a description, title, and copyright notice. Professional photographers usually include at least the necessary copyright and authorship information. Some editorial teams also use external media management systems to centrally manage media metadata.
Since imperia 11.4, it is now user-friendly to extract metadata from media during the upload process and use them internally. However, media metadata can also pose security risks, as confidential information stored in the metadata can be inadvertently exposed when publishing a webpage. With imperia 11.4, you can sanitize media during upload and preserve only harmless information.
Upload Templates for Different File Types#
Conditional statements can be used to load different templates with different input fields for different file types. Fields that make sense for image files may not be relevant for PDF documents. Differentiation is done on the level of individual input fields using conditional statements (IF, ELSIF, ELSE), as you are familiar with from imperia template language. The function used to evaluate the temporarily uploaded file is XX-ASSET. Here's an example of using the function in a conditional statement:
#IF ("<!--XX-ASSET(File:MIMEType):1-->" REQ "^image\/")
All input fields for image files
#ELSIF ("<!--XX-ASSET(File:MIMEType):1-->" REQ "^application\/pdf$")
All input fields for PDF documents
#ELSE
All input fields for other file types
#ENDIF