Created
May 28, 2020 14:32
-
-
Save ericvalois/5b1e161c127632a1ace7d65ce1363e69 to your computer and use it in GitHub Desktop.
Remove WordPress responsive image markups (sizes, srcset) for SVG images
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
/* | |
* 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