Skip to content

Instantly share code, notes, and snippets.

@tareq1988
Created May 23, 2014 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tareq1988/9d988690af0901357ead to your computer and use it in GitHub Desktop.
Save tareq1988/9d988690af0901357ead to your computer and use it in GitHub Desktop.
Relative image url
<?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