WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/05/2016 12:44:28 AM (3 years ago)
Author:
davidakennedy
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyseventeen/template-parts/post/content-video.php

    r39072 r39146  
    4141    <?php
    4242        $content = apply_filters( 'the_content', get_the_content() );
    43         $video = get_media_embedded_in_content( $content, array( 'video', 'object', 'embed', 'iframe' ) );
     43        $video = false;
     44
     45        // Only get video from the content if a playlist isn't present.
     46        if ( false === strpos( $content, 'wp-playlist-script' ) ) {
     47            $video = get_media_embedded_in_content( $content, array( 'video', 'object', 'embed', 'iframe' ) );
     48        }
    4449    ?>
    4550
Note: See TracChangeset for help on using the changeset viewer.