Skip to content

Instantly share code, notes, and snippets.

@prasadnevase
Created February 16, 2021 08:06
Show Gist options
  • Save prasadnevase/3356e186245f0f938aca179408e6d6d7 to your computer and use it in GitHub Desktop.
Save prasadnevase/3356e186245f0f938aca179408e6d6d7 to your computer and use it in GitHub Desktop.
WordPress - render LIVE site media on local setup
<?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