ressio / lazy-load-xt

Lazy load XT is a jQuery plugin for images, videos and other media
http://ress.io/lazy-load-xt-jquery/
MIT License
1.36k stars 245 forks source link

Throwing away URL after comma? #60

Open alexandrethsilva opened 8 years ago

alexandrethsilva commented 8 years ago

Hi @ressio, thanks a lot for this nice and handy lib!

I noticed an issue just now after I started setting up Cloudinary on our project.

Cloudinary itself is a hosted service for resizing and caching images from a given website and the way it works is through URL parameters.

They take it in this format (as you can see on this link):

http://res.cloudinary.com/demo/image/upload/w_{WIDTH},h_{HEIGHT},{CROP_TYPE},{OTHER_PARAMS}/sample.png

As you can see, the params are separated by commas, which is valid syntax.

The problem is that Lazy Load XT is throwing out everything that comes after the first comma and therefore brakes my URLs. :disappointed:

That is, it transforms this:

http://my.domain.com/image/upload/h_684,c_fill/v1443702170/image.jpg

Into this (even though the data-srcset shows the correct URL):

http://my.domain.com/image/upload/h_684

Do you have a perspective what what you could do there?

alexandrethsilva commented 8 years ago

For what I see, the problem is the collision with the Responsive Images feature from the lib that you explain here.

Which are apparently parsed on this piece of code, inside the jquery.lazyloadxt.srcset.js:

var list = srcset.split(',').map(function (item) { //<=== This split fellow, here.
  return {
    url: reUrl.exec(item)[1],
    w: parseFloat((reWidth.exec(item) || infty)[1]),
    h: parseFloat((reHeight.exec(item) || infty)[1]),
    x: parseFloat((reDpr.exec(item) || one)[1])
  };
});

I find it a nice feature to have, but if it breaks valid URL formats I'd suggest the syntax of the lib is change to something else... What's your opinion there?

I can make a pull request with a suggestion if you prefer.

klibansky commented 7 years ago

I'm having this same issue. @dryabov Are you using another lib in the mean time?