PHP WordPress - Filter Max Image Width for SRCSET

<?php // Set max width function filter_max_srcset( $max_width, $size_array ) { $original_width = $size_array [ 0 ]; $original_height = $size_array [ 1 ]; $max_width = 768; return $max_width; } add_filter( 'max_srcset_image_width', 'filter_max_srcset', 10, 2 ); // Remove max width (1600px) restriction function remove_max_srcset_image_width( $max_width ) { return false; } add_filter( 'max_srcset_image_width', 'remove_max_srcset_image_width' );

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.