Skip to content

Instantly share code, notes, and snippets.

@wpscholar
Last active April 5, 2022 08:57
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save wpscholar/079757d344992c4bd418 to your computer and use it in GitHub Desktop.
Save wpscholar/079757d344992c4bd418 to your computer and use it in GitHub Desktop.
Load media from a remote site so you don't have to download the uploads directory.
<?php
/**
* Loads media from a remote site when on a local dev environment.
* Eliminates the need to download the uploads directory from the remote site for testing purposes.
*/
if ( 'mydomain.dev' === $_SERVER['HTTP_HOST'] ):
add_filter( 'upload_dir', function ( $uploads ) {
$uploads['baseurl'] = 'http://mydomain.com/wp-content/uploads';
return $uploads;
} );
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment