Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify srcset/sizes on img (was: Tweak example 3) #90

Closed
zcorpan opened this issue Jan 7, 2014 · 7 comments · Fixed by #95
Closed

Specify srcset/sizes on img (was: Tweak example 3) #90

zcorpan opened this issue Jan 7, 2014 · 7 comments · Fixed by #95

Comments

@zcorpan
Copy link

zcorpan commented Jan 7, 2014

This example is in the spec:

<picture>
 <source media="(min-width: 45em)" srcset="large-1.jpg, large-2.jpg 2x">
 <source media="(min-width: 18em)" srcset="med-1.jpg, med-2.jpg 2x">
 <source srcset="small-1.jpg, small-2.jpg 2x">
 <img src="small-1.jpg" alt="The president giving an award." width="500" height="500">
</picture>

I think this could be:

<picture>
 <source media="(min-width: 45em)" srcset="large-1.jpg, large-2.jpg 2x">
 <source media="(min-width: 18em)" srcset="med-1.jpg, med-2.jpg 2x">
 <img src="small-1.jpg" srcset="small-2.jpg 2x" alt="The president giving an award." width="500" height="500">
</picture>

right?

@yoavweiss
Copy link
Member

It can be, assuming that srcset's DPR switching in img is here to stay.

I think there are 3 options forward with regard to srcset@img:

  1. Leave its DPR switching as is, which would mean srcset is different between <img> and <source>
  2. Modify it to match <source>'s srcset, which would probably mean adding a sizes element to <img>.
  3. Drop it entirely, leaving only srcset@source

I'm in favor of 2, but I'm not sure it won't complicate matters.

@zcorpan
Copy link
Author

zcorpan commented Jan 7, 2014

I think we should specify (2), that seems best for authors long-term.

@Wilto
Copy link
Member

Wilto commented Jan 7, 2014

Agreed on option two.

@igrigorik
Copy link

Re, option 2: at which point we might as well add media to img and get rid of source? :P

Just playing devils advocate.. I'm not convinced the extra complexity is worth it. What's so special about source that allows it to have media whereas img has all other functionality? FWIW, I'd +1 option 3.

@yoavweiss
Copy link
Member

I'm not convinced the extra complexity is worth it

I'm not 100% convinced either, but I'm not sure what that complexity is. I don't think specifying it would be complicated (@tabatkins - correct me if I'm wrong). I don't think implementing it would be significantly complicated either (the syntax parsers can be reused, etc).

The advantage of 2, is that is enables to get rid of the last source of the picture markup, and if there's only one source (i.e. no art-direction), it enables to support variable width images and DPR switching without <picture> at all.

3 is simpler in the sense that it gives the developer less options.

@tabatkins - What do you say?

@zcorpan
Copy link
Author

zcorpan commented Jan 7, 2014

(2) is probably less complexity compared to the current situation with different specs for <source srcset> and <img srcset>.

As to why not use img instead of source: it wouldn't have a good back-compat story, I don't know what the algorithm would be like, and the markup would look pretty confusing I think.

(3) would mean that it's not OK to ship a subset implementation of only <img srcset>.

@tabatkins
Copy link

I think #2 is fine. I haven't done it yet only because I was trying to leave <img> alone, but I recognize that it's probably the best way forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants