Last active
June 21, 2021 08:59
-
-
Save axcellence/221fa2f3759404827f1293326b2e9174 to your computer and use it in GitHub Desktop.
Drop these in mu-plugins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin name: Remote Media Loader | |
* Description: Save local storage space by mapping you /uploads directory to your staging or production site | |
* Author: Axl Crawford | |
* Author uri: https://www.barques.co.uk/ | |
* License: MIT | |
*/ | |
// Exclude http:// | |
$local_url = "myproject.local"; | |
// Include http:// or https:// | |
$remote_url = "https://myproject.dev"; | |
if ( $local_url === $_SERVER['HTTP_HOST'] ){ | |
add_filter( 'upload_dir', function ( $uploads ) { | |
$uploads['baseurl'] = "$remote_url/wp-content/uploads"; | |
return $uploads; | |
} ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment