BE Media from Production
When spinning up a staging or local development environment, you might not need the full uploads directory, but you also don’t want to see broken images throughout the site.
This plugin lets you use the production server for missing media. Define the production URL using a wp-config.php constant BE_MEDIA_FROM_PRODUCTION_URL
or filter be_media_from_production_url
.
In all cases, if a local file exists, it will be used in preference to the remote file.
Installation with wp cli
wp plugin install https://github.com/billerickson/be-media-from-production/archive/master.zip --force --activate
wp config set BE_MEDIA_FROM_PRODUCTION_URL https://www.billerickson.net --type=constant
Code language: JavaScript (javascript)
Installation with Code Snippet
Download the plugin from GitHub and upload it to your site. Then, inside a Code Snippets plugin, create a PHP code snippet to define the production URL:
add_filter( 'be_media_from_production_url', function() {
return 'https://www.billerickson.net';
});
Code language: JavaScript (javascript)
BigScoots integration
BigScoots, our preferred WordPress managed host, has built our plugin directly into their staging environment creation process.
The default selection is “Create Staging and exclude uploads”, which will automatically exclude the uploads directory, install BE Media from Production, and add the constant to wp-config.php defining the production URL.
It’s a seamless process that saves you time in creating staging as well as conserving disk space.
When you click “Push to Live”, the default option will sync any uploads you’ve made to staging into your live site’s uploads directory, before pushing the database, theme, and plugins.