Fix header image filtering and YouTube header video detection#1208
Fix header image filtering and YouTube header video detection#1208westonruter merged 2 commits intodevelopfrom
Conversation
* Make sure that any get_header_image_tag filters from theme get applied. Fixes quality issue in Twenty Seventeen. * Fix detection of YouTube short URLs. * Dequeue wp-custom-header instead of deregistering to prevent Query Monitor complaining.
c01fabd to
4445c18
Compare
kienstra
left a comment
There was a problem hiding this comment.
Approved
Hi @westonruter,
This PR looks good. It's nice how it accommodates URLs like https://youtu.be/v5zg_Yv048s.
Nice "before" and "after" images and markup. I also saw how this PR enables outputting the layout attribute on the header image.
| remove_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce' ); | ||
| add_filter( 'wp_kses_allowed_html', array( __CLASS__, 'whitelist_layout_in_wp_kses_allowed_html' ), 10 ); | ||
| add_filter( 'get_header_image_tag', array( __CLASS__, 'conditionally_output_header' ), 10, 3 ); | ||
| add_filter( 'get_header_image_tag', array( __CLASS__, 'amend_header_image_with_video_header' ), PHP_INT_MAX ); |
There was a problem hiding this comment.
It's nice how this allows all other filters to run first.
| * @see AMP_Theme_Support::conditionally_output_header() | ||
| * @see AMP_Theme_Support::amend_header_image_with_video_header() | ||
| */ | ||
| public function conditionally_output_header() { |
There was a problem hiding this comment.
This is an error I made in a commit, but this method conditionally_output_header() should have been test_conditionally_output_header().
But with the method renamed, this method should probably be test_amend_header_image_with_video_header().
| $image_header = AMP_HTML_Utils::build_tag( 'amp-img', $atts ); | ||
| $youtube_id = null; | ||
| if ( isset( $parsed_url['host'] ) && preg_match( '/(^|\.)(youtube\.com|youtu\.be)$/', $parsed_url['host'] ) ) { | ||
| if ( 'youtu.be' === $parsed_url['host'] && ! empty( $parsed_url['path'] ) ) { |
There was a problem hiding this comment.
It's nice how this accounts for URLs like https://youtu.be/v5zg_Yv048s
Amends #1074. See #1078.
get_header_image_tagfilters from theme get applied. Fixes quality issue in Twenty Seventeen. Seetwentyseventeen_header_image_tag().wp-custom-headerinstead of deregistering to prevent Query Monitor complaining about missing scripts.Before 🚫
Notice the low resolution image:
After ✅
Notice high resolution image: