Provide a placeholder element for Twitter embeds - #1753
Conversation
d84c7b0 to
90861ae
Compare
|
Also, this also needs to be done for <figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio">
<div class="wp-block-embed__wrapper">
<iframe title="Finding Portland" width="640" height="360" src="https://www.youtube.com/embed/8EtmqU844hU?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</figure>And the AMP version is: <figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-has-aspect-ratio">
<div class="wp-block-embed__wrapper">
<amp-youtube data-videoid="8EtmqU844hU" layout="responsive" width="640" height="360"></amp-youtube>
</div>
</figure>In actuality, the AMP version should have <figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-has-aspect-ratio">
<div class="wp-block-embed__wrapper">
<amp-youtube data-videoid="8EtmqU844hU" layout="responsive" width="640" height="360">
<a fallback href="https://www.youtube.com/watch?v=8EtmqU844hU">Finding Portland</a>
</amp-youtube>
</div>
</figure>This will ensure that the linked content is accessible to search engines and also for users who have JS turned off. This should be done generally for all embeds. For YouTube in particular, a <figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-has-aspect-ratio">
<div class="wp-block-embed__wrapper">
<amp-youtube data-videoid="8EtmqU844hU" layout="responsive" width="640" height="360">
<a fallback href="https://www.youtube.com/watch?v=8EtmqU844hU">Finding Portland</a>
<amp-img placeholder src="https://img.youtube.com/vi/8EtmqU844hU/maxresdefault.jpg" layout="fill"></amp-img>
</amp-youtube>
</div>
</figure> |
90861ae to
4ce50e9
Compare
4ce50e9 to
18f39dc
Compare
18f39dc to
a9ed369
Compare
|
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
|
@googlebot I consent. |
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
|
@westonruter should there also be a fallback element for |
|
I don't think so because the |
|
Ah that's what I thought as well, but the PR title made me think different. |
pierlon
left a comment
There was a problem hiding this comment.
No issues to report here, ![]()
| add_filter( 'embed_oembed_html', [ $this, 'filter_embed_oembed_html' ], 10, 2 ); | ||
| add_shortcode( 'tweet', [ $this, 'shortcode' ] ); // Note: This is a Jetpack shortcode. | ||
| wp_embed_register_handler( 'amp-twitter', self::URL_PATTERN, [ $this, 'oembed' ], -1 ); | ||
| wp_embed_register_handler( 'amp-twitter-timeline', self::URL_PATTERN_TIMELINE, [ $this, 'oembed_timeline' ], -1 ); |
There was a problem hiding this comment.
Eventually the same thing should be done for Twitter timelines.
| * @return string Rendered oEmbed. | ||
| */ | ||
| public function oembed( $matches ) { | ||
| _deprecated_function( __FUNCTION__, '1.1' ); |
There was a problem hiding this comment.
| _deprecated_function( __FUNCTION__, '1.1' ); | |
| _deprecated_function( __METHOD__, '1.1' ); |

Refer to prior work on SoundCloud embeds (#2722) and YouTube embeds (#3358).
Todo:
amp-twitter.Use YouTube poster image linked to YouTube URL as theSee Provide a placeholder element for Twitter embeds #1753 (comment). Done in Improve handling of YouTube embeds #3358.fallbackcontent foramp-youtube.Twitter
Before:
After: