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
Elements with decimal dimensions cause AMP validation errors in i-amphtml-sizer for Optimized/Transformed AMP #27528
Comments
cc @ampproject/wg-caching @sebastianbenz |
According to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img:
I think this would indicate that the bug is in accepting non-integer widths for amp-img, if any, but I don't think we could reverse that decision at this point. |
So this is squarely an Optimizer bug? |
My argument is that there is also a bug in that the validator accepts decimal widths for amp-img, but that this is probably not a bug we can fix at this point due to the risk of de-validating documents. One could also interpret the spec of I suppose we could relax this in the validator anyway if you think that would be easier than the optimizer. I'm not sure if it would hurt anything. |
Agree with Greg, it probably makes sense to relax the validator rules for the intrinsic sizer (at least the behavior is then consistently wrong). That's not something that should be fixed on optimizer side. |
Decimal values for If we wanted to only output valid HTML5, then an alternative would be to use CSS to specify the sub-pixel widths: <img src="data:image/svg+xml;charset=utf-8,<svg style="height:938px;width:1333.8226950355px" xmlns="http://www.w3.org/2000/svg" version="1.1"/>" alt="" aria-hidden="true" class="i-amphtml-intrinsic-sizer" role="presentation" > |
So should this be reopened? Let me know the direction which will be taken. We'll probably do a hotfix to the AMP plugin to force integer values to be used while waiting for a potential validator update. |
Sure. Reopening. Would you be willing to make the PR for the validator change? |
I can but @sebastianbenz would probably be able to get to it first. |
This also fixes hard coded image dimensions. Fixes ampproject#27528
This also fixes hard coded image dimensions. Fixes #27528
Originally reported in ampproject/amp-wp#4493.
Given input HTML like so:
Take note of the decimal value in the
width
. This is valid AMP.When the Optimizer is enabled (in both the Node.js and PHP version), this gets optimized as:
Which is not valid AMP. A validation error is raised:
When the AMP optimizer is disabled, the AMP runtime is generating constructing the DOM as follows:
Note that the decimal width is used here as well. This indicates that the validator spec is at fault here, namely the
IMG-I-AMPHTML-INTRINSIC-SIZER
spec which defines thesrc
attribute to have avalue_regex
as follows:amphtml/validator/validator-main.protoascii
Line 4879 in 2984894
This needs to be changed to allow for decimal values, for example:
The text was updated successfully, but these errors were encountered: