Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/billerickson/BE-Media-from-Production
Uses local media when it's available, and uses the production server for rest.
https://github.com/billerickson/BE-Media-from-Production
Last synced: about 1 month ago
JSON representation
Uses local media when it's available, and uses the production server for rest.
- Host: GitHub
- URL: https://github.com/billerickson/BE-Media-from-Production
- Owner: billerickson
- License: gpl-3.0
- Created: 2016-01-22T15:01:14.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-08-11T19:03:01.000Z (over 1 year ago)
- Last Synced: 2024-02-15T17:32:04.345Z (10 months ago)
- Language: PHP
- Homepage:
- Size: 43.9 KB
- Stars: 196
- Watchers: 12
- Forks: 26
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-wp-developer-tools - BE Media from Production - Uses local media when available, and uses the production server for the rest. (WordPress Plugins)
README
# BE Media from Production
Contributors: billerickson,magicroundabout
Requires at least: 4.3
Tested up to: 6.6
Stable tag: 1.8.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.htmlUses local media when available, and uses the production server for the rest.
## Description
When redesigning a website with a large uploads directory, you might not need all those uploads in your development
or staging environment, 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 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
Once the plugin is installed, add the following constant to wp-config.php with your production URL.
```
define( 'BE_MEDIA_FROM_PRODUCTION_URL', 'https://www.billerickson.net' );
```Alternatively, you can use the filter in your theme's functions.php file, a core functionality plugin, or a mu-plugin:
```
add_filter( 'be_media_from_production_url', function() {
return 'https://www.billerickson.net';
});
```## Installation via WP-CLI and constants
```
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
```## Using with WP Migrate
[WP Migrate](https://deliciousbrains.com/wp-migrate-db-pro/) is my preferred tool for pushing/pulling databases between environments. The media files functionality allows you to transfer media between environments along with the database.
When redesigning a website, I keep all the media on my development server and push up new media uploads along with the database.
Set up a "push" profile to push your local database to the development server. Make sure "Media Files" is checked and select "Compare, then upload".
Set up a "pull" profile to pull the development database locally. Do not include media in your pull. Any missing media will be handled by BE Media from Production.