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
Definitively fix issues with images in AMP not visually matching non-AMP version #2036
Conversation
For some reason the |
OK, that seems fixed now by 6677c3b. |
As noted in ampproject/amphtml#21371 (comment) I added the Bison image test post to the environment:
|
7e6230a
to
034ac82
Compare
…inc also get object-fit:contain This guards against image stretching. See <ampproject/amphtml#21371 (comment)>. Props @cathyxz
…t is essentially alignwide
AMP will generate the sizes attribute for us. Removing the sizes attribute also fixes many issues with images getting unexpected width being set.
034ac82
to
0180357
Compare
* @todo: remove when this is resolved: https://github.com/ampproject/amphtml/issues/17053 | ||
* @since 1.0 | ||
*/ | ||
public static function remove_twentynineteen_thumbnail_image_sizes() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's great to be able to remove these workarounds!
Brief Testing Hi @westonruter, It looks like sometimes large images are a different size in AMP and non-AMP. Though the biggest problem before was distortion, and that doesn't look to be an issue. Steps to reproduce
Non-AMPAMP |
@kienstra I think this is just an issue with your local environment. Note the image has the class name It appears as expected. |
In other words, your image is failing because the plugin wasn't able to perform the HTTP request to determine the dimensions. |
Thanks, @westonruter. That makes sense. I'll review this PR. |
Approved Hi @westonruter, It's really nice that these workarounds aren't needed anymore. (Stealing your great table formatting above)
The only images that look different in AMP have As expected, there's no reference PR #17053 anymore in the plugin, like here. |
/** Force the image into a box of fixed dimensions and use object-fit to scale. **/ | ||
object-fit: contain; | ||
} | ||
<?php echo file_get_contents( AMP__DIR__ . '/assets/css/amp-default.css' ); // phpcs:ignore WordPress.WP.AlternativeFunctions ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea to echo amp-default.css
here.
@kienstra I'm a bit concerned to see stretching here: This should not be happening even when the sizes are unknown due to |
Build for testing: amp.zip (v1.1-alpha-20190405T220345Z-9246809c)
This PR seeks to finally lay to rest the multitude of issues we've faced regarding
amp-img
not behaving like the correspondingimg
. A key piece to this is that thesizes
attribute can now be removed fromamp-img
and the AMP runtime will (soon) compute it automatically; see ampproject/amphtml#19513.Fixes issues including:
See screenshots below to compare.
Fixes #1747. Fixes #1305.
See #1656, #1104, #1237, #1086.
Closes #1939.
The post content I've been using to test is as follows. I tried to consider every scenario for where an image can appear:
Desktop
Mobile
Classic Templates
Please note that the Classic templates generally lack styles for blocks in general, so there are some issues that aren't related to images here.