Created
May 23, 2014 15:55
-
-
Save tareq1988/9d988690af0901357ead to your computer and use it in GitHub Desktop.
Relative image url
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 | |
function wedevs_replace_image_url( $file ) { | |
if ( is_array( $file ) && isset( $file['src'] ) ) { | |
$file['src'] = str_replace( home_url(), '', $file['src'] ); | |
} | |
return $file; | |
} | |
add_filter( 'wp_get_attachment_image_attributes', 'wedevs_replace_image_url' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment