-
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
Images on attachment page appear stretched #1237
Comments
Seems Related To Inline Styling This looks to only exist when using the It looks like the https://paired-ampconfdemo.pantheonsite.io/image-alignment-150x150/?amp <amp-img ... sizes="100vw" layout="intrinsic" style="width: 100vw;"> In the example above, the Still, maybe the inline styling of |
Bringing @kienstra and my conversation here. The inline width styling is applied by AMP (not our plugin) from the Here's what AMP Docs say about the attributes:
Reading deeper into the AMP's docs about
The width of the image then is set by the value in the Compare AMP to non-AMP versionsLet's compare the difference between AMP and non-AMP attachments to see if we can find the solution: Here is the non-AMP HTML:
Here is the AMP version of that attachment:
The differences include:
Let's look at the CSS rules added by those extra class attributes:
Possible Solutions@kienstra notes some possible solutions above. Option A: Remove the inline width style. Removing the inline width style also requires us to set the display to Option B: Target the width of the parent container. AMP's Tips & Tricks section suggests setting the parent container's max-width. Attachments use This possible solution would ensure the image does not stretch. |
@kienstra @hellofromtonya I'm sure you've seen this already, but just to make clear that the source of the problem is Twenty Seventeen's That being the case, the solution chosen could perhaps be made part of the It could be that the issue here is a fundamental incompatibility between So a similar approach may be needed here. In fact, the existing |
Hi @westonruter, Could we wait a little on this issue, to see what happens with amphtml/17053? There's discussion there about possibly changing the |
Excellent. I'm glad you raised that. |
…hment page. Per issue #1237, the Twenty Seventeen theme is adding `$attr['sizes'] = '100vw';` which stretches images on the attachment page when in AMP mode. The attachment image's width This commit filters 'wp_get_attachment_image_attributes' to change the layout to responsive and sizes to the image sizes per `wp_get_attachment_image_sizes()`. AMP uses these attributes to render the <amp-img>.
…hment page. Per issue #1237, the Twenty Seventeen theme is adding `$attr['sizes'] = '100vw';` which stretches images on the attachment page when in AMP mode. This commit filters 'wp_get_attachment_image_attributes' to change the layout to responsive and sizes to the image sizes per `wp_get_attachment_image_sizes()`. AMP uses these attributes to render the <amp-img>.
@westonruter and @kienstra Upon further investigation, we can remedy the Twenty Seventeen theme's image stretching issue by filtering the attachment image's attributes and changing the following:
IMO these attribute fixes are not a bandaid but rather a fix for how the theme is setting the |
For reference, PR #1321 fixes this specific issue. However, since we have an open issue with the AMPHTML project, let's keep this issue open until that one is resolved. Once resolved, we can come back and validate this issue to ensure there are no regression problems. |
Moving To 'Ready For Merging' It looks like the Issue for the AMP project probably won't be fixed by this plugin's stable So I'm moving this to 'Ready For Merging' if that's alright, as this already has a merged PR that fixes the issue. |
Moving Out Of Milestone As this is only tracking ampproject/amphtml#17053, I'm moving this out of the |
This is being revisited in #2036. Please test. |
In Twenty Seventeen at least, an image on the attachment template looks stretched:
Non-AMP version:
The text was updated successfully, but these errors were encountered: