Skip to content

Instantly share code, notes, and snippets.

@jawngee
Last active December 17, 2018 09:46
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 jawngee/3d7c57f4b458f24e76a21618cada157a to your computer and use it in GitHub Desktop.
Save jawngee/3d7c57f4b458f24e76a21618cada157a to your computer and use it in GitHub Desktop.
Disable srcset generation
<?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