get_resource_path

Returns a URL or file path for a resource file.

Variable Description Data type Default value
$ref * The ID of the resource or an array of resource IDs. Note: when an array of IDs is passed, make sure the array is a subset of resource IDs grouped by extension, size and other parameters required by get_resource_path() in order to get the expected path returned. Example: if you are requesting the original file path of two resources, an image and a video, and you are requesting extension "jpg" then the video path will be incorrect as that was supposed to have a "mp4" extension instead (or any other video extension). integer
$not_used N/A null
$size The ID for the size requested (e.g. "scr" for screen size). Leave empty for the original file. string ""
$generate If the path does not yet exist on disk, create it. bit (0 or 1) 1
$extension The file extension requested. This can be found from the extension property of the search results or resource data queries. string "jpg"
$page Which page to return, in the case of a request for a preview of a multi-page document. Leave empty for the first page. integer 1
$watermarked Fetch a watermarked version of the image? Leave empty for non-watermarked. bit (0 or 1) 0
$alternative The ID of an alternative file to return. Leave empty for the original file. integer -1

Return values

A temporary URL which can be used to download the requested resource file, or false if there was an issue. If $ref is an array of IDs then the returned value will be an array with resource ID as index and the temporary download URL as value. If $ref is a single ID then the returned value will be a string containing the URL. 

The URL provided will normally be valid for 24 hours (see configuration below), long enough to transfer the file to the remote system for later use.

Related config options

The config option $api_resource_path_expiry_hours can be configured to set the number of hours before the access_key appended to the returned URL expires. By default it is 24 hours.