grunt-cdnify icon indicating copy to clipboard operation
grunt-cdnify copied to clipboard

Add support for srcset attribute URLs in img tag

Open anvaynk opened this issue 7 years ago • 5 comments

Need to include the feature to match the list of urls contained in srcset attribute of an image tag!!

anvaynk avatar Jan 30 '18 09:01 anvaynk

Doesn't it work if you add it in your config?

XhmikosR avatar Jan 31 '18 14:01 XhmikosR

The thing is that if we add multiple urls with different device pixel ratios(DPR), it encodes the DPR alongwith the urls, this should not happen.

anvaynk avatar Feb 01 '18 05:02 anvaynk

That is a different issue and you should provide a test case for that.

XhmikosR avatar Feb 01 '18 06:02 XhmikosR

@XhmikosR Unfortunately srcset doesn't work properly. Consider this example for html: <img src="image.jpg" alt="image" srcset=" image-1024_2x.jpg 1024w, image-1224.jpg 1224w, image-1400.jpg 1340w, image-2800_2x.jpg 1340w, image-480.jpg 480w, image-768.jpg 768w, image.jpg 1340w ">

After running grunt task it became: <img src="//some.b-cdn.net/image.jpg" alt="image" srcset="//some.b-cdn.net/image-1024_2x.jpg%201024w,%20image-1224.jpg%201224w,%20image-1400.jpg%201340w,%20image-2800_2x.jpg%201340w,%20image-480.jpg%20480w,%20image-768.jpg%20768w,%20image.jpg%201340w">

in the gruntfile I've added inside options.html this line: 'img[srcset]': 'srcset',

The issue here is that there is a simple string rewrite and srcset should be treat as an array.

kokers avatar Sep 26 '18 20:09 kokers

PR's welcome as usual.

XhmikosR avatar Sep 26 '18 23:09 XhmikosR