4oh3 / live-files
Serves images (and optionally other public files) from the live site instead of the local files directory. Intended for local development only.
1.1.0
2026-10-19 15:47 UTC
Requires
- drupal/core: ^10 || ^11
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Live Files serves images (and optionally other public files) from your live site, so a local copy of a Drupal site displays them without the files directory. Intended for local development only.
Installation
With Composer
composer require --dev 4oh3/live-files drush en live_files -y
Without Composer
- Download main.zip.
- Unzip it into your custom modules folder (e.g.
web/modules/custom) and rename thelive-files-mainfolder tolive_files. - Enable the module:
drush en live_files -y
Configuration
Enter the live site URL at Configuration → Development → Live files (/admin/config/development/live-files), or set it with Drush:
drush cset live_files.settings base_url https://www.example.com -y
Keep it out of config sync
Add this to your local-only settings.local.php so the module is never exported with drush cex (and deployed to production), and isn't uninstalled when you run drush cim:
$settings['config_exclude_modules'] = ['live_files'];
Settings
- Live site URL: for example
https://www.example.com. Leave empty to serve everything locally. Enter the address only. Browsers block image URLs that contain a username and password, so do not put htaccess credentials in this field. - Files to serve from the live site: all files, or only files missing locally.
- Non-image files: optionally serve PDFs, documents and video from the live site too.
- HTTP authentication: optional username and password for a live site protected by htaccess. This site fetches those files and sends the credentials. The password is stored in the module configuration. Leave both empty for a public live site. Clear the username and save to remove a stored password.
How it works
- File URLs generated by Drupal (image fields, image styles, responsive images, media, Twig
image_style/file_url) are rewritten to point at the live site. - Requests for missing local files (e.g. images hard-coded in body text or CSS) are redirected to the same path on the live site.
- With HTTP authentication set, those URLs stay on the local site. The local site fetches the file from the live site and sends the username and password.
- A file that exists on this site but not on the live site, such as one just uploaded, is served from this site. Image styles for that file are generated here.
- Image styles for files that exist only on the live site may not load when they have never been generated there, because the
itoktoken is built with the local hash salt.