Twenty Seventeen: Fix playlists not rendering on blog/archive pages when using video or audio post format

TwentySeventeen attempts to highlight media found in post content by using `get_media_embedded_in_content()` to extract videos from the content and display their HTML differently. However, the HTML being generated by the playlist shortcode relies on JavaScript to update the video element with the markup needed to display the playlist properly. The `get_media_embedded_in_content()` function wasn't designed to handle this use case.

The patch looks for the presence of `wp-playlist-script` in the content and shows the standard content rather than trying to pluck the media elements from the content using `get_media_embedded_in_content()`.

Props joemcgill.

Fixes #38390.


git-svn-id: https://develop.svn.wordpress.org/trunk@39146 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
David A. Kennedy 2016-11-05 00:44:28 +00:00
parent 5d832bc2ae
commit d93ca46c4f
2 changed files with 13 additions and 2 deletions

View File

@ -41,7 +41,13 @@
<?php <?php
$content = apply_filters( 'the_content', get_the_content() ); $content = apply_filters( 'the_content', get_the_content() );
$audio = false;
// Only get audio from the content if a playlist isn't present.
if ( false === strpos( $content, 'wp-playlist-script' ) ) {
$audio = get_media_embedded_in_content( $content, array( 'audio' ) ); $audio = get_media_embedded_in_content( $content, array( 'audio' ) );
}
?> ?>
<?php if ( '' !== get_the_post_thumbnail() && ! is_single() ) : ?> <?php if ( '' !== get_the_post_thumbnail() && ! is_single() ) : ?>

View File

@ -40,7 +40,12 @@
<?php <?php
$content = apply_filters( 'the_content', get_the_content() ); $content = apply_filters( 'the_content', get_the_content() );
$video = false;
// Only get video from the content if a playlist isn't present.
if ( false === strpos( $content, 'wp-playlist-script' ) ) {
$video = get_media_embedded_in_content( $content, array( 'video', 'object', 'embed', 'iframe' ) ); $video = get_media_embedded_in_content( $content, array( 'video', 'object', 'embed', 'iframe' ) );
}
?> ?>
<?php if ( '' !== get_the_post_thumbnail() && ! is_single() && empty( $video ) ) : ?> <?php if ( '' !== get_the_post_thumbnail() && ! is_single() && empty( $video ) ) : ?>