WordPress srcset: how to and chrome issue

User avatar
axew3
w3all User
w3all User
Posts: 2712
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

WordPress srcset: how to and chrome issue

Post by axew3 »

Code: Select all

function w3all_ht_custom_image_srcset( $sources, $size_array, $image_src, $image_meta, $attachment_id ){

	$w = get_custom_header()->width;

// srcset val
		$sources[$w] = array(
				 'url'        => 'myurlimage.jpg',
				 'descriptor' => 'w',
				 'value'      => $w,
		);
			return $sources;
		
	}
	add_filter( 'wp_calculate_image_srcset', 'w3all_ht_custom_image_srcset', 10, 5 );
	
the problem is, on chrome, the filter seem to be applied not only to header image, as correctly done by all others browsers, but also, if for example on post gallery, to all others gallery images, that are appearing in this way:
ScreenHunter_69-Jul.-06-10..jpg
ScreenHunter_69-Jul.-06-10..jpg (50.61 KiB) Viewed 1028 times
instead than as on others tested browsers, in the correct way:
ScreenHunter2.jpg
ScreenHunter2.jpg (12.02 KiB) Viewed 1028 times