Make WordPress Core

Changeset 39146


Ignore:
Timestamp:
11/05/2016 12:44:28 AM (8 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.

Location:
trunk/src/wp-content/themes/twentyseventeen/template-parts/post
Files:
2 edited

Legend:

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

    r39072 r39146  
    4242    <?php
    4343        $content = apply_filters( 'the_content', get_the_content() );
    44         $audio = get_media_embedded_in_content( $content, array( 'audio' ) );
     44        $audio = false;
     45
     46        // Only get audio from the content if a playlist isn't present.
     47        if ( false === strpos( $content, 'wp-playlist-script' ) ) {
     48            $audio = get_media_embedded_in_content( $content, array( 'audio' ) );
     49        }
     50
    4551    ?>
    4652
  • 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.