Skip to content

Instantly share code, notes, and snippets.

@Rupashdas
Last active April 22, 2024 06:20
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 Rupashdas/b81f21a1abfd1cb4120971c41112bd33 to your computer and use it in GitHub Desktop.
Save Rupashdas/b81f21a1abfd1cb4120971c41112bd33 to your computer and use it in GitHub Desktop.
<?php
function devrupash_remove_max_srcset_image_width( $max_width ) {
return false;
}
add_filter( 'max_srcset_image_width', 'devrupash_remove_max_srcset_image_width' );
function devrupash_disable_srcset( $sources ) {
return false;
}
add_filter( 'wp_calculate_image_srcset', 'devrupash_disable_srcset' );
function devrupash_remove_width_attribute( $html ) {
$html = preg_replace( '/(width|height)="\d*"\s/', "", $html );
return $html;
}
add_filter( 'wp_get_attachment_image', 'devrupash_remove_width_attribute', 10 );
add_filter( 'post_thumbnail_html', 'devrupash_remove_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'devrupash_remove_width_attribute', 10 );
function devrupash_disable_image_compression() {
return 100;
}
add_filter( 'wp_editor_set_quality', 'devrupash_disable_image_compression');
add_filter( 'jpeg_quality', 'devrupash_disable_image_compression' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment