• Great plugin and great feature! Let me start with that! ??

    I recently ran into the problem that I have several Youtube Playlists embedded and those are, I think not supported (yet). Which would be totally fine, but the plugin crashes on it. In script ..\src\Providers\YouTube.php, function get_data_from_api() there’s the following view lines of code:

    if ( $api_key ) {
    $request = sprintf( self::CONTENT_DETAILS_URL, $video_id, $api_key );
    $request = wp_remote_get( $request, array( 'timeout' => $this->get_timeout() ) );

    if ( wp_remote_retrieve_response_code( $request ) === 200 ) {
    $body = wp_remote_retrieve_body( $request );
    $body = json_decode( $body, false );
    $content_details = $body->items[0]->contentDetails;
    $snippet = $body->items[0]->snippet;

    $result = [
    'duration' => $content_details->duration,
    'name' => $snippet->title,
    'description' => $this->sanitize_video_description( $snippet->description ),
    'upload_date' => $snippet->publishedAt,
    ];
    }
    } else {

    When it’s a playlist $body->items[0] is empty (I think) and $this->sanitize_video_description( $snippet->description ) crashes when it tries to retrieve the description.

    I use a quick fix to set it to ” like this:

    if( empty( $body ) || empty( $body->items[0] ) ) {
    $snippet = (object)null;
    $snippet->description = "";
    } else {
    $content_details = $body->items[0]->contentDetails;
    $snippet = $body->items[0]->snippet;
    }

    But that only avoids the crash and doesn’t return something nice. So one looses the description and the image.

    Youtube’s embed code just retrieves the image and title of the first video in the playlist and only shows that it is a playlist when you click play.

    It would be awesome to have that feature included in this plugin too!

  • You must be logged in to reply to this topic.