-
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
Intent-to-Deprecate: amp-img
#30442
Comments
First off, amazing! What about other replacement tags, like |
Isn't there an existing issue for this? See #29786 |
There is an existing issue @westonruter. The other issue was closed and moved here as the original proposal has changed. Edit: I was mistaken, but have closed the other issue now as this updated proposal is taking feedback from the last conversation into account. |
@pbakaus This is the first attempt at moving away from custom elements for features that have been implemented natively at the element level. Those items you mention are worth looking into as well, but there is more custom behavior present that might delay migration and/or deprecation. |
I think the main thing that makes |
We will need to update some code in amp-story:
amp-story-360:
cc @ampproject/wg-stories |
To echo @gmajoulet point. I believe we also need to update some code in AMP components that handles layout of its children (e.g. Based on what I found image lazy load only applies to element below viewport. |
If I understand this correctly, this represents a significant departure from Is there anything available here that would allow us to enforce this layout? Adding image dimensions has been a burden for many publishers, and I can see them being happy to just set If we are comfortable about losing this enforcement, I recommend we do not require width/height in validation. |
IMHO we should still require width and height for validation. They are intrinsic data about the image and any recommendation about the layout would be based on these values. The final layout confirmation will have to be left to CLS. |
@dvoytenko Do you see anything preventing this rule from just turning into teams setting |
This is true today, one can use any value for width and height to get the validator to pass. Is the concern that for web developers they will not see an issue besides the impact to Web Vitals? If this is the case, does it make sense to recommend using Pixi more within the Validator? |
It's possible we change the workflow to Pixi. But looking at the current rules that we have. A native
I'd just stress that (1) without the (2) is even worse for CLS than wrong values. |
We could force AMP's current behavior with |
I don't think this is the case? Both of these result in 1x1 elements on the page after it is loaded (without any layout shifting): <amp-img width="1" height="1" src="https://amp.dev/static/img/case-band-image-1.png"></amp-img>
<img width="1" height="1" loading="lazy" decoding="async" src="https://amp.dev/static/img/case-band-image-1.png"> As I understand, if an author provides an incorrect |
Right. @cramforce I think the simple abuse looks something similar to:
|
My proposal would mitigate that. |
@cramforce Where does that CSS live? Is that part of the AMP CSS, boilerplate, or something we expect publishers to add? |
AMP CSS |
Will deprecation of |
@westonruter I believe, yes, the hope is to eventually allow |
Deprecation of |
It's been well over a year now since this issue was raised, any progress? The amp-img tag causes many issues with WordPress responsiveness. It's been a constant battle of CSS bandaids trying to get images to look good across devices. Getting rid of the amp-img tag would make AMP WordPress dev much more effective. The fact this has been an open issue for so long makes me question whether developing for AMP is worth it anymore. |
Apologies for the delay, at this point the only item remaining is in validation. The caching working group is looking to address as they have availability. |
@kristoferbaxter Thanks for the quick reply. Is there any timeline for the caching working group, i.e. finding time in the next couple of weeks, months, etc.? |
@Gregable Thoughts on timeline for validator changes? |
@banaag who has taken over for this. Cache work is done pending release, and validator work is active. I suspect we'll have it working by end of month, but with holidays it could possibly go a little further. |
Thanks for the update Greg! |
@kristoferbaxter What about #30958? Have extensions been updated to support native |
@westonruter – I believe this is finished. |
I've opened ampproject/amp-wp#6805 to use native |
@fthead9 You can try native images in the AMP plugin for WordPress by installing the latest 2.2.x production pre-release build, and enabling the opt-in flag with this WordPress plugin PHP code: add_filter( 'amp_native_img_used', '__return_true' ); The result is a valid AMP page that uses |
So can this issue be closed now? |
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. |
Summary
We would like to allow developers who write AMP to be able to use the native html
img
tag, use transforms to change existingamp-img
tags to nativeimg
tags and after sufficient time removeamp-img
from v0 and make it an optional component.Motivation
The
amp-img
component was primarily created in order to allow for lazy-loading of images in amp pages in order to improve page performance. At the time the native htmlimg
tag did not allow for this which necessitated the creation of a custom extension.Today however, the native
img
tag does allow for lazy loading through the use of theloading
attribute. As a result theamp-img
extension is no longer needed to achieve the performance improvements for which it was originally created.Because of this the
amp-img
extension will need to be constantly updated in order to maintain feature parity with the native htmlimg
tag or risk obsolescence.In the long term we would like to turn down the use of
amp-img
in new amp documents, instead allowing developers to use the native htmlimg
tag with theloading
attribute set to lazy in order to achieve these results. This would remove the burden on amp contributors to constantly maintain feature parity and will additionally allow developers to create simple documents without needing to learn the usage of an extra amp extension.Impact on existing users
This change will allow users to use native
img
in future development.Additionally existing AMP documents which are run through transformers will be modified to replace all existing
amp-img
tags withimg
tags.This will cause the following changes to the
amp-img
features:Loading placeholder will no longer exist
The blurry image placeholder will need to be implemented with a background image.
The
sizes
attribute will no longer be calculated automatically.height
andwidth
attributes will be requiredThe
loading
attribute will be required and set tolazy
. (not supported on IE)In order to achieve 1:1 visual parity the native images will also require
display:block
andmargin:0
which are both automatically applied byamp-img
css.Examples:
Sizes/Aspect-ratio - https://glitch.com/edit/#!/amp-img-to-img
Blurry Image placeholder - https://glitch.com/edit/#!/amp-img-blurry-placeholder?path=amp.html%3A77%3A21
Alternative implementation suggestion for developers using AMP
Developers will now be able to use native
img
instead ofamp-img
.We will offer developers the following guidance in order to achieve similar functionality that is offered to
amp-img
Use
loading= “lazy”
The
height
andwidth
attributes will respect the actual size of the image, this will cause CLS if they are incorrect therefore for the best experience make sure you use the correct width and height.Use
display: block
andmargin: 0
which amp automatically applies.When using
srcset
you must use sizes in addition in order to verify that the appropriately sized image is selected.Deprecation Plan
Step 1: Allow developers to use native
img
in valid amp pages.Step 2: Use transformers to change
amp-img
to nativeimg
Step 3: Wait
Step 4: Remove
amp-img
from the module runtime, because all documents in this runtime have passed through a transformer we are guaranteed that they will only have nativeimg
Step 5: Either remove
amp-img
entirely, or removeamp-img
from v0 and convert it into a regular AMP extension./cc @ampproject/wg-approvers
The text was updated successfully, but these errors were encountered: