Skip to content

Instantly share code, notes, and snippets.

@jdevalk
Created December 7, 2012 08:35
Show Gist options
  • Select an option

  • Save jdevalk/4231810 to your computer and use it in GitHub Desktop.

Select an option

Save jdevalk/4231810 to your computer and use it in GitHub Desktop.
Include thumbnail from custom field for JW Player video's
<?php
// You can add the code below to your theme's functions.php
/**
* Filter the vid array to include thumbnail.
*
* @param array $vid The video array as determined by the indexation process
*
* @return array
*/
function filter_jwplayer_thumb( $vid ) {
if ( !isset( $vid['post_id'] ) )
return $vid;
$thumb = get_post_meta( $vid['post_id'], 'thumb', true );
if ( $thumb && !empty( $thumb ) ) {
// If it's a relative link, make it absolute.
if ( strpos( $thumb, 'http' ) !== 0 )
$thumb = rtrim( home_url(), '/' ) . $thumb;
$vid['thumbnail_loc'] = $thumb;
}
return $vid;
}
add_filter( 'wpseo_video_jwplayer_details', 'filter_jwplayer_thumb' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment