Skip to content
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

Prevent AMP validation errors from unnecessary code in responsive-videos module extra #13205

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions modules/theme-tools/responsive-videos.php
Expand Up @@ -42,6 +42,11 @@ function jetpack_responsive_videos_embed_html( $html ) {
return $html;
}

// Short-circuit for AMP responses, since custom scripts are not allowed in AMP and videos are naturally responsive.
if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {
return $html;
}

// The customizer video widget wraps videos with a class of wp-video
// mejs as of 4.9 apparently resizes videos too which causes issues
// skip the video if it is wrapped in wp-video.
Expand Down Expand Up @@ -79,6 +84,11 @@ function jetpack_responsive_videos_maybe_wrap_oembed( $html, $url = null ) {
return $html;
}

// Short-circuit for AMP responses, since custom scripts are not allowed in AMP and videos are naturally responsive.
if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {
return $html;
}

$jetpack_video_wrapper = '<div class="jetpack-video-wrapper">';

$already_wrapped = strpos( $html, $jetpack_video_wrapper );
Expand Down