Rate limiting is in place on the Direct Link Cache endpoints. Please read our support article on rate limiting for more information.
Note: In older versions of Asset Bank 'Folders' were called 'Access Levels'
The Direct Link Cache provides an action (URL) that converts and returns an image based on request parameters. If the conversion has previously been completed then the image is returned from a cache.
The action receives the following parameters:
- assetId or attributeId + attributeValue (mandatory)
- width (mandatory)
- height (mandatory)
- cropToFit (optional) - this defaults to true, so set 'cropToFit=false' if you just want the image to be scaled
- preserveAspectRatio (optional)
- preserveColorSpace (optional)
- download (optional) - e.g. for retrieving a video asset
- format (optional) - the image format to retrieve (valid values are: jpg, gif or png).
- fillBackground (optional) - fill the background of the bounding box if cropToFit=false
- fillBackgroundColour (optional) - specify the background fill colour in hexadecimal - six characters are required but no hash character, e.g black would be fillBackgroundColour=000000
This action will return an image created from the asset where the specified attribute has the specified value or where the asset's id matches the given assetId parameter (if it matches a non-image asset then an error code will be returned, and if the value matches more than one asset then an arbitrary asset will be chosen from the matching ones).
The attribute referred to by attributeId must be a textual attribute (e.g. it cannot be a date or dropdown).
The returned image will have a maximum pixel size defined by the width and height parameters. By default, the aspect ratio of the original image will be maintained and the image will be resized and cropped as required so it completely fills a bounding box of width X height pixels. Alternatively, if the cropToFit parameter is specified and has a value of false the aspect ratio will be maintained but no cropping will take place such that the image will fit, but may not completely fill the bounding box. By default, the requested image will be converted to the RGB colour space unless the preserveColorSpace is set to true. Finally, if both the cropToFit and preserveAspectRatio parameters are specified and have values of false no cropping will take place and the image will be stretched and/or squashed so it completely fills the bounding box
If the format parameter is passed then the resulting image should be returned in the format requested. If the format isn't specified then the image will be a GIF if the source image is a GIF, a PNG if the source is PNG and a JPEG otherwise.
Before creating the image Asset Bank will check to see if it already has the required image (including size) in a cache – if so it will return the cached version. Cached versions will be deleted if the source image is changed, or its asset record is deleted.
To define which assets can be used by the Direct Link Cache, it is assigned a dedicated Group that permissions can be set in the Admin > Groups area of Asset Bank. This Group is often called 'Direct Link Group' or something similar.
If a requested image is not in a Folder that is visible to this Group then the action will return a ‘no permission’ code (HTTP status code 403) If the application setting does not contain a valid Group ID then the new action will return the ‘no permission’ code for all requests.
URLs to call the action will look like this:
Using asset ID:
...assetbank-example/action/directLinkImage?assetId=297&width=1000&height=1000
Using an attribute to match on:
...assetbank-example/action/directLinkImage?attributeId=4&attributeValue=MyImage&width=1000&height=1000
Downloading the target file (i.e. a download dialogue will be shown):
...assetbank-example/action/directLinkImage?assetId=297&download=true
Comments
0 comments
Please sign in to leave a comment.