Created
December 7, 2012 08:35
-
-
Save jdevalk/4231810 to your computer and use it in GitHub Desktop.
Include thumbnail from custom field for JW Player video's
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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