Created
November 28, 2012 08:54
-
-
Save jdevalk/4159989 to your computer and use it in GitHub Desktop.
Filter the video array of the Video SEO plugin to include duration from a custom field
This file contains 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 | |
/** | |
* Filter the vid array to include duration. | |
* | |
* @param array $vid The video array as determined by the indexation process | |
* | |
* @return array | |
*/ | |
function filter_jwplayer_duration( $vid ) { | |
if ( !isset( $vid['post_id'] ) ) | |
return $vid; | |
$duration = get_post_meta( $vid['post_id'], 'duration', true ); | |
if ( !$duration ) | |
$duration = get_post_meta( $vid['post_id'], 'Duration', true ); | |
if ( $duration && !empty( $duration ) ) | |
$vid['duration'] = $duration; | |
return $vid; | |
} | |
add_filter( 'wpseo_video_jwplayer_details', 'filter_jwplayer_duration' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment