jimboobrien
9/20/2017 - 10:44 PM

Load media from a remote site so you don't have to download the uploads directory.

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;