WordPress srcset: how to and chrome issue

Post a reply


This question is a means of preventing automated form submissions by spambots.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

If you wish to attach one or more files enter the details below.

Maximum filesize per attachment: 1 MiB.

Expand view Topic review: WordPress srcset: how to and chrome issue

WordPress srcset: how to and chrome issue

by axew3 » Wed Jul 06, 2016 9:03 am

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

Top