grunt-cdnify
grunt-cdnify copied to clipboard
Add support for srcset attribute URLs in img tag
Need to include the feature to match the list of urls contained in srcset attribute of an image tag!!
Doesn't it work if you add it in your config?
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.
That is a different issue and you should provide a test case for that.
@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.
PR's welcome as usual.