-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
amp-lightbox-gallery: Different images for thumbnail and detail #21736
Comments
Thanks @machal for the feedback. I agree the correct solution is not very ergonomic. Maybe we can have an API like:
/cc @cathyxz |
I still suggest using The reasoning here is because it's not possible to animate the transition from one image to a second image with a different aspect ratio because it's not possible to programmatically figure out how that translates, so supporting different aspect ratio means no transition animation. If we are ok with doing no transition or doing a fade transition, then the second API will probably work better, since that allows us to still make use of |
@cathyxz Thanks for idea with The case with But I think there should be an extra option with You may consider it. |
A few thoughts here:
Option 1 here and
both allow more developer control as opposed to leaving it up to the browser's discretion. |
The idea with <picture>
<amp-img src="thumbnail.jpg" media="(max-width: 599px)"
layout="responsive" width="200" height="200" alt="…" lightbox>
<amp-img src="detail.jpg" media="(min-width: 600px)"
layout="responsive" width="1600" height="900" alt="…"></amp-img>
</picture> Looks good for me and – because it is the standard – it should be one of the options. But for lot of developers it will be hard to think/write in comparison with Another problem is that my initial |
You can do crops with a combination of One problem here would be specifying the scale / object position for the child amp-img img {
transform: var(--img-transform);
object-position: var(--img-object-position);
} <amp-img src="..." style="--img-transform: scale(2); --img-object-position: center bottom"></amp-img> I suppose one useful thing would be to have a tool to generate the correct DOM structure / CSS when cropping to a specific portion of an image. |
This is still a work in progress, but here is a tool where you can choose an image, then select an area to crop and it will give you the HTML you need: https://sparhami.github.io/animations/docs/tools/img-cropper/?output=amp |
@aghassemi |
I'd love to see this implemented soon as well because it makes the lightbox totally unusable in the most generic case of having smaller thumbs and larger full sized images. Right now it doesn't seem to be possible to have a gallery with low-res image thumbs because once tapped, the image that is then loaded into view is the thumb and not the full size. That'd be like the web existing without What am I missing? How's it possible amp-lightbox-gallery doesn't support the most basic use case for lightbox galleries? |
You can already do this. You can use This does: <amp-img
layout="fixed"
width="135" height="90"
lightbox
srcset="https://cdn.glitch.com/e7729dec-fc32-4f68-8d6e-13ef08b88715%2Fbeach-small.jpg?v=1566332064756 338w,
https://cdn.glitch.com/e7729dec-fc32-4f68-8d6e-13ef08b88715%2Fbeach.jpg?v=1566331576281 1350w"
sizes="135px"
</amp-img> This uses causes the lower resolution thumb to be picked when the content is in the page, and a higher resolution one to be picked for the gallery. There is no extra bandwidth being wasted here to download the high resolution image. The page also contains examples of cropping using Is there a particular example page where this is not working for you? |
Let's summarize this issue. There are two topics here: 1) Implement
|
@sparhami So I'm afraid that the case mentioned by @archon810 is not solved with your solution.
|
So you can leave off https://furtive-octagon.glitch.me <amp-img
layout="responsive"
width="135" height="90"
lightbox
srcset="https://cdn.glitch.com/e7729dec-fc32-4f68-8d6e-13ef08b88715%2Fbeach-small.jpg?v=1566332064756 338w,
https://cdn.glitch.com/e7729dec-fc32-4f68-8d6e-13ef08b88715%2Fbeach.jpg?v=1566331576281 1350w">
</amp-img> For some reason, this isn't picking the correct source in Chrome devtools device emulation mode, but the sizes media query is being generated correctly. If you don't do device emulation, and just narrow the window, it should work correctly in Chrome / Firefox. You can check which source was used by finding the This will pick the smaller resolution on a narrow screen, and the larger one on a wider screen. Note that the |
@sparhami it loads the big image, so that is not the solution. |
In the screenshot above, I loaded the page with a window width of 327 pixels (which is under the 338 declared in the srcset), and got the small image. After resizing it I correctly get the larger image. What window width are you using? It should definitely load the smaller one if the page was loaded with the correct dimensions. When I load the page with a width of 337 pixels, I correctly get the smaller image. With 339, I correctly get the larger image. Note that with srcset, if you go past a smaller size (in the example above, if your width is over 339 pixels), it will jump up to the next size and does not try to find the nearest size. For the example, I created only two sizes, but in practice, you will want to generate more intermediate steps. I believe the image picked also takes into the display pixel density, |
I know how the srcset works, so thats why I'm pointing out that it's not the solution for the case mentioned byt @machal and @archon810 |
I'm testing this stuff on Chrome emulator for Windows with window.devicePixelRatio=2, and I can't make sense of the results and can't seem to get to the desired solution that @maciejmackowiak and I would want (well, sort of - see the ending). The easiest way to test is in incognito and with We need to emulate the aforementioned scenario where we only have 2 images - a small thumb (always 215px wide in this example) and a potentially really large original image. No matter the device viewport, we'd like the thumb to load until clicked on, and then the original image to load - just what you'd expect from Using your own images:
https://lightbox-300-10000.glitch.me/: -small loads until 867px (why?):
The last example would probably work for our purposes, but I'd really love to understand why it switches at that particular breakpoint, how universal the solution would be, and whether we're thinking about the whole thing the wrong way. |
@sparhami Like in this example: Is it possible to implement this solution(or something similar): |
Ideally, #24223 adds an
to always pick the lower resolution image. You should also be able to just set |
Rooting for #24223. Wonder when it might land in stable. |
Can we get this issue moving toward a solution please? |
@archon810 Is the new |
Hey @caroqliu
We need a solution to have only two images, first one is always used for displaying it on a page and second one is always used for lightbox gallery. Thanks in advance |
Thanks for clarifying -- to be clear, the The
This means it should be possible to target the underlying |
@caroqliu I'm not sure, if it solves situation when we want:
As me and @maciejmackowiak wrote: <a href='full.jpg'><img src='thumb.jpg'></a> |
The <amp-img
layout="responsive"
width="135"
height="90"
lightbox
srcset="https://cdn.glitch.com/e7729dec-fc32-4f68-8d6e-13ef08b88715%2Fbeach-small.jpg?v=1566332064756 338w,
https://cdn.glitch.com/e7729dec-fc32-4f68-8d6e-13ef08b88715%2Fbeach.jpg?v=1566331576281 1350w"
sizes="337px"
disable-inline-width
>
</amp-img> |
@caroqliu Thanks for reply! But wasn't What I want with And more – nobody still explained, why this so usual and popular code pattern like |
Could you describe more what is not possible about the code pattern? I was able to create this working, valid sample: https://jsbin.com/vejasojiti/1/edit?html,output |
@caroqliu This is not what we want. Your example contains What we want is to open full size image in lightbox, like here: https://dbrekalo.github.io/simpleLightbox/ Originally we wanted to add this functionality with markup like this into AMP lightbox: <a href="detail.jpg"><!-- <- Opens in lightbox -->
<amp-img src="thumbnail.jpg">
</a> |
I see, thank you for illustrating the issue further, and for your patience in communicating your goals to a few of us. 😄 This sounds like the UX is current achievable with the I recognize that it's not the pattern you are most familiar with, nor is it very ergonomic. I'm happy to keep the issue open until the exact usage pattern described here is available in AMP, but as far as I'm aware we don't have the bandwidth to implement this soon. |
@caroqliu Thank you very much, Caroline. I'm proposing this pattern not because I need it, but because of its simplicity which most jQuery users like. Will be great, if AMP will add it. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
Please reopen and implement something to solve this issue! I have photo galleries on user profiles. The full size images that end users upload could be of wildly different sizes and ratios. The large original I would like to open in the lightbox view, whilst the common, possibly cropped 3:2 thumbnail is visible on the page as the lightbox trigger. |
Describe the new feature or change to an existing feature you'd like to see
Feature request for simple use case of the
amp-lightbox-gallery
component. Like in jQuery plugins:Describe alternatives you've considered
I've tried to do it with
srcset
/sizes
as recommended in #14900 and other issues and I've ended with following code:Live website: https://www.vzhurudolu.cz/amp/kurzy/rychlost-nacitani
Issues I can see here:
sizes
attribute is difficult.The text was updated successfully, but these errors were encountered: