Skip to content

Instantly share code, notes, and snippets.

@ericvalois
Created May 28, 2020 14:32
Show Gist options
  • Save ericvalois/5b1e161c127632a1ace7d65ce1363e69 to your computer and use it in GitHub Desktop.
Save ericvalois/5b1e161c127632a1ace7d65ce1363e69 to your computer and use it in GitHub Desktop.
Remove WordPress responsive image markups (sizes, srcset) for SVG images
/*
* Remove wordpress responsive image markup for SVG
*/
add_filter( 'wp_calculate_image_sizes', 'remove_svgt_responsive_image_attr', 10, 3 );
function remove_svgt_responsive_image_attr( string $sizes, array $size, $image_src = null ) {
$explode = explode( '.', $image_src );
$image_type = end( $explode );
if( $image_type === "svg" ){
$sizes = "";
}
return $sizes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment