Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sitemaps: Add thumbnails to video sitemaps #11449

Merged
merged 5 commits into from
Mar 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion modules/sitemaps/sitemap-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,20 @@ private function video_post_to_sitemap_item( $post ) {

/** This filter is already documented in core/wp-includes/feed.php */
$content = apply_filters( 'the_content_feed', $content, 'rss2' );

// Include thumbnails for VideoPress videos, use blank image for others
if ( 'complete' === get_post_meta( $post->ID, 'videopress_status', true ) && has_post_thumbnail( $post ) ) {
$video_thumbnail_url = get_the_post_thumbnail_url( $post );
} else {
/**
* Filter the thumbnail image used in the video sitemap for non-VideoPress videos.
*
* @since 7.2.0
*
* @param string $str Image URL.
*/
$video_thumbnail_url = apply_filters( 'jetpack_video_sitemap_default_thumbnail', 'https://s0.wp.com/i/blank.jpg' );
}

$item_array = array(
'url' => array(
Expand All @@ -1327,7 +1341,7 @@ private function video_post_to_sitemap_item( $post ) {
'video:video' => array(
/** This filter is already documented in core/wp-includes/feed.php */
'video:title' => apply_filters( 'the_title_rss', $post->post_title ),
'video:thumbnail_loc' => '',
'video:thumbnail_loc' => esc_url( $video_thumbnail_url ),
'video:description' => $content,
'video:content_loc' => esc_url( wp_get_attachment_url( $post->ID ) ),
),
Expand Down