Last active
December 17, 2018 09:46
-
-
Save jawngee/3d7c57f4b458f24e76a21618cada157a to your computer and use it in GitHub Desktop.
Disable srcset generation
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 | |
// Add to your functions.php | |
// Disable SRCSET | |
add_filter('wp_get_attachment_image_attributes', function($attr) { | |
if (isset($attr['sizes'])) { | |
unset($attr['sizes']); | |
} | |
if (isset($attr['srcset'])) { | |
unset($attr['srcset']); | |
} | |
return $attr; | |
}, PHP_INT_MAX); | |
// Override the calculated image sources | |
add_filter('wp_calculate_image_srcset', '__return_empty_array', PHP_INT_MAX); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment