-
Notifications
You must be signed in to change notification settings - Fork 800
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
Add AMP compatibility for Pinterest block #17086
Add AMP compatibility for Pinterest block #17086
Conversation
Thank you for the great PR description! When this PR is ready for review, please apply the E2E results is available here (for debugging purposes): https://jetpack-e2e-dashboard.herokuapp.com/pr-17086 Scheduled Jetpack release: October 6, 2020. |
Co-authored-by: Jeremy Herve <jeremy@tagada.hu>
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.
This works well for pins. It won't work for boards or user profiles though. I wonder if this may be worth mentioning in the docblock of the render_amp
function, so our future selves don't get surprised about this?
// Fallback embed when info is not available. | ||
$amp_pinterest = sprintf( | ||
'<amp-pinterest data-do="embedPin" data-url="%s" width="%d" height="%d"></amp-pinterest></div>', | ||
esc_url( $attr['url'] ), | ||
450, // Fallback width. | ||
750 // Fallback height. | ||
); |
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.
If we do not have info about the pin (like when embedding a user profile such as https://pinterest.com/anapinskywalker/
), is it worth using the amp-pinterest
tag? Wouldn't we be better off just outputting a link?
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.
I'm trying to embed https://pinterest.com/anapinskywalker/
in the Pinterest block but it's not doing anything. Is that expected?
Clicking Embed does nothing. So a user wouldn't be able to embed non-pins anyway, right?
But yes, it would be better to show a link if a non-pin ended up getting embedded.
Otherwise, if the only issue is the info request fails, then it still seems a bit better to render amp-pinterest
rather than just a bare URL link. While the size of the Pin may be not ideal, at least it should be showing the Pin.
I'm also going to open an issue in the amphtml repo to request that the width
/height
of amp-pinterest
be optional in the same way as they are for amp-twitter
or amp-gist
. It is too tedious to get the dimensions exactly right. So once the embed initializes, it should resize itself to fit its contents even if this causes some CLS. This is an instance of where AMP needs to be pragmatic.
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.
So once the embed initializes, it should resize itself to fit its contents even if this causes some CLS. This is an instance of where AMP needs to be pragmatic.
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.
If we do not have info about the pin (like when embedding a user profile such as
https://pinterest.com/anapinskywalker/
), is it worth using theamp-pinterest
tag? Wouldn't we be better off just outputting a link?
I've added a link to render as a fallback in this case: b9e4f62.
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.
I'm trying to embed https://pinterest.com/anapinskywalker/ in the Pinterest block but it's not doing anything. Is that expected?
That's odd. It seems to work well on my end:
This is a test account set up by Pinterest themselves, but you could try with just about any other profile:
r213307-wpcom |
Co-authored-by: Jeremy Herve <jeremy@tagada.hu>
See #14395.
This PR adds AMP compatibility for the Pinterest block.
Given this block content:
The before/after results are as follows:
The behavior is even improved over the non-AMP version in that it also renders fallback content when JavaScript is turned off.
Note that the AMP plugin also has basic support for rendering Pinterest embeds by registering an oEmbed handler: https://github.com/ampproject/amp-wp/blob/develop/includes/embeds/class-amp-pinterest-embed-handler.php
Nevertheless, the Jetpack implementation in this PR is far superior in that it correctly sets the width/height of the component, includes metadata, and also placeholder/fallback content.
Changes proposed in this Pull Request:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
Proposed changelog entry for your changes: