Attempts to fetch missing asset files from a remote host, by intercepting 404 errors.

Installs: 86

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 2


dev-master 2017-11-19 04:43 UTC

This package is auto-updated.

Last update: 2024-06-11 13:59:03 UTC



Attempts to fetch missing asset files from a remote host, by intercepting 404 errors. The idea is to download missing asset files from staging/production sites on-demand, without needing to do full syncs of the assets folder.

Unfortunately, out-of-the-box this will NOT WORK with SilverStripe's default image handling, because these don't generate image tags / URLs (needed to trigger 404s) if the images don't exist locally. There are two methods for getting images to work, see Methods under Usage.

There is a similar issue with File objects; the template expression <% if $File %> will return false if the file does not exist locally, so it is suggested to use something like <% if $File.ID %> instead, to test if a file link should be displayed.


After installing the module, define an ASSETPROXY_SOURCE constant in either _config.php or _ss_environment.php:


Method 1 - Automatic Image Handling

For automatic image handling, the core Image and Image_Cached classes need to be replaced with AssetProxy's extended versions:

    class: AssetProxy_Image
    class: AssetProxy_Image_Cached

This overrides the methods necessary to make AssetProxy work automatically (unfortunately this is not possible via Extensions).

Method 2 - Use Image Profiles module

Instead of replacing the core Image classes (which may conflict with certain setups) you can use this module in conjunction with Image Profiles, and template code like $Image.Original or $Image.ProfileName, which will always output an image tag and subsequently trigger the download via 404 handling.

This method is highly recommended as it has other benefits, such as not handling image manipulation on the main page request (which can cause delays in page load time). However it does require a modified approach to how you deal with images in templates.

Suggested Modules

  • Image Profiles - A "non-blocking" approach to image handling, using configurable profiles. If you want to use Method 2 above, this module is a requirement.
  • Backup/Restore - Super simple downloading/uploading MySQL DB dump files from within the CMS.

Using these three modules together makes for environment-sync heaven! Effortlessly sync the database from production (or staging), and any missing images & files will automagically show up on-demand.

Known Issues

  • If the source image is changed (while retaining an identical filename) the new version will not replace the old one. Suggested workaround is to just delete your local version of the file and let the latest be re-fetched.