Skip to content

Instantly share code, notes, and snippets.

@ethicka
Created February 26, 2021 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ethicka/c212091113c9da01dc282acf6cd6bf62 to your computer and use it in GitHub Desktop.
Save ethicka/c212091113c9da01dc282acf6cd6bf62 to your computer and use it in GitHub Desktop.
Load wp-content/uploads from the remote site
<?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.
* Replace WEBSITE with you domain name.
*/
if ('WEBSITE.local' === $_SERVER['HTTP_HOST']) :
add_filter('upload_dir', function ($uploads) {
$uploads['baseurl'] = 'https:/WEBSITE.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