Page 1 of 1

WordPress srcset: how to and chrome issue

Posted: Wed Jul 06, 2016 9:03 am
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 1113 times
instead than as on others tested browsers, in the correct way:
ScreenHunter2.jpg
ScreenHunter2.jpg (12.02 KiB) Viewed 1113 times