-
Notifications
You must be signed in to change notification settings - Fork 385
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
All images in a post have lightbox when no image is explicitly opted into lightbox #5122
Comments
See also #3579 (comment). So the answer to that question apparently is yes: we still do need the lightbox toggle. |
Here's a mini plugin that adds the the I think it makes sense to go ahead and update the plugin to do this by default. Maybe there should be a filter to control whether the attribute is added, but it would be added by default. |
Note that even when |
As opposed to a filter, enabling/disabling the auto-lightbox functionality could be an advanced option on the Settings screen. There may be some other such settings that would be relevant in such a section, such as whether galleries should by default use a carousel and/or lightbox per #4989 (comment). I'm just wary of adding too many settings. If we find that most users benefit from something being enabled (or disabled) we should just do it and provide an API to override the default behavior. If there are more than 20% of users who would be wanting to override the default, then in that case the UI would make sense. |
As of now, I have added the filter to disable the auto lightbox. (by default auto lightbox will be enabled). Let me know if we should add a UI for that option. cc: @westonruter |
No UI is needed, no. But let's disable the auto-lightbox by default. See https://github.com/ampproject/amp-wp/pull/6936/files#r822046774. |
To test this, try with a theme like Twenty Seventeen. I found that auto-lightbox didn't engage in Twenty Twenty or Twenty Twenty-One because they already use lightboxes. |
QA Passed ✅ Before: Image had lightbox effect even if lightbox toggle was off Screen.Recording.2022-03-23.at.12.18.04.PM.movAfter: Image is displayed in lightbox only if lightbox toggle is enabled Screen.Recording.2022-03-23.at.12.19.38.PM.mov |
Bug Description
With this plugin active on a site, any page that (a) contains one or more
amp-img
es and (b) doesn't have lightboxing explicitly turned on for anyamp-img
receives auto lightboxing for all images on the page. This document pretty much explains why: https://github.com/ampproject/amphtml/blob/master/spec/auto-lightbox.mdWhile auto-lightboxing is probably fine for many sites, there are cases where it's not desirable -- e.g. very small images tend not to look great when expanded into a lightbox, and decorative graphical elements generally don't benefit from the lightbox.
Expected Behaviour
Image blocks with "Add lightbox effect" toggled off should never have a lightbox.
Perhaps the plugin could make it possible to opt out of auto lightboxing at the post level. Where auto lightboxing is disabled, however, it should still be possible to enable the lightbox for individual images using the "Add lightbox effect" toggle.
On the project where this came up, we did just that -- we added a post meta field to the editor sidebar, to the effect of "Disable lightbox for this post." When this is on, we add
data-amp-auto-lightbox-disable
to the element wrapping the post content. When this attribute is present, images with "Add lightbox effect" turned on still have the lightbox. This approach could be difficult to implement from the plugin, though, because the plugin can't easily modify the theme's markup. The attribute could be added to thebody
tag, maybe.Steps to reproduce
develop
branch)Additional context
develop
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
data-amp-auto-lightbox-disable
attribute should be added to thebody
.Implementation brief
See https://gist.github.com/westonruter/b6691407af1648b402b09371a9faf7f0
AMP_Auto_Lightbox_Disable_Sanitizer
which sets thedata-amp-auto-lightbox-disable
attribute on thebody
.amp_get_content_sanitizers()
, conditionally add this sanitizer to the$sanitizers
ifapply_filters( 'amp_auto_lightbox_disabled', true )
returnsfalse
.QA testing instructions
Demo
Changelog entry
The text was updated successfully, but these errors were encountered: