Last active
July 26, 2016 16:18
-
-
Save emaildano/2142edb13bf24acca56b0addd5da0129 to your computer and use it in GitHub Desktop.
Serve Remote Assets WP Function
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
add_filter('upload_dir', 'set_upload_folder', 999); | |
function set_upload_folder( $upload_data ) { | |
// absolute dir path, must be writable by wordpress | |
$upload_data['basedir'] = trailingslashit(ABSPATH). '/wp-content/uploads'; | |
$upload_data['baseurl'] = 'http://example.com/wp-content/uploads'; | |
$subdir = $upload_data['subdir']; | |
$upload_data['path'] = $upload_data['basedir'] . $subdir; | |
$upload_data['url'] = $upload_data['baseurl'] . $subdir; | |
return wp_parse_args($upload_data, $upload_data); | |
} |
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
// Serve Remote Uploads | |
function remote_uploads() { | |
return 'http://example.com/app/uploads'; | |
} | |
add_filter( 'pre_option_upload_url_path', 'remote_uploads' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment