Created
February 16, 2021 08:06
-
-
Save prasadnevase/3356e186245f0f938aca179408e6d6d7 to your computer and use it in GitHub Desktop.
WordPress - render LIVE site media on local setup
This file contains hidden or 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 | |
// Replace the https://livesite.com/ with actual URL | |
add_filter( 'wp_get_attachment_url', function( $url, $attachment_id ) { | |
return str_replace( home_url(), 'https://livesite.com/', $url ); | |
}, 99, 2 ); | |
// Replace the https://livesite.com/ with actual URL | |
add_filter( 'wp_get_attachment_image_src', function( $image, $attachment_id ) { | |
$image[0] = str_replace( home_url(), 'https://livesite.com/', $image[0] ); | |
return $image; | |
}, 99, 2 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment