dev-master
9999999-dev http://github.com/bcairns/silverstripe-assetproxyAttempts to fetch missing asset files from a remote host, by intercepting 404 errors.
BSD-3-Clause
The Requires
by Brian Cairns
assets silverstripe remote download staging
Wallogit.com
2017 © Pedro Peláez
Attempts to fetch missing asset files from a remote host, by intercepting 404 errors.
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., (*1)
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., (*2)
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., (*3)
After installing the module, define an ASSETPROXY_SOURCE constant in either _config.php or _ss_environment.php:, (*4)
define('ASSETPROXY_SOURCE','http://my-source-server.com');
For automatic image handling, the core Image and Image_Cached classes need to be replaced with AssetProxy's extended versions:, (*5)
Injector:
Image:
class: AssetProxy_Image
Image_Cached:
class: AssetProxy_Image_Cached
This overrides the methods necessary to make AssetProxy work automatically (unfortunately this is not possible via Extensions)., (*6)
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., (*7)
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., (*8)
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., (*9)
Attempts to fetch missing asset files from a remote host, by intercepting 404 errors.
BSD-3-Clause
assets silverstripe remote download staging