Configuring the download filename format
From version 10.3, ResourceSpace has a new system wide configuration that allows administrators to format the final download filename. This usually applies for a resource (or its alternatives), including preview sizes.
To view this video please enable JavaScript, and consider upgrading to a web browser that supports HTML5 video
Available placeholders
Placeholder | Description | Notes |
%resource | The resource ID. | |
%extension | The file extension of the original file, for example "jpg", "png" etc. | |
%filename | The original file name. | For alternatives this is the name (which is usually the original filename unless it was edited). |
%fieldXX | The value of a metadata field on the resource, where XX is the metadata field ID. | If the user doesn't have permission to view the field, then blank (empty string) will be used instead. |
%size | The three character ID of the preview size being downloaded, for example "scr", "pre" etc. For more info see manage sizes. | When applicable, an underscore will be automatically prefixed. |
%alternative | The resource alternatives' ID. | When applicable, an underscore will be automatically prefixed. |
It's important to understand that with greater flexibility comes more responsibility on the administrators' side. ResourceSpace will try its best to honour the admins' desired format with a few exceptions:
- If the configuration option is blanked out, the system will use the following default format:
- RS%resource_%filename%size.%extension
- Invalid characters will be removed.
- If the filename length is too long (e.g. because of %fieldXX use), it will be truncated.
- When, mostly due to some internal failure, ResourceSpace didn't get to parse the desired format, the system will fallback to using only "RS%resource.%extension".
Examples
Note: the below examples can be set from the system wide configuration page by just copying the format (without single quotes).
Showing your company name, resource, its size and extension:
$download_filename_format = 'YourCompanyName-%resource%size.%extension';
Only showing the resource and its size:
$download_filename_format = 'RS%resource%size';
Static string with the resource, its size, alternative (if applicable) and extension:
$download_filename_format = 'Source-RS-%resource%size%alternative.%extension';
Using other metadata fields (related to the downloaded resource) to build the filename. For example, using the Country (#3) and Credit (#10) :
$download_filename_format = 'RS-%resource-%field3-%field10.%extension';