Skip to content

Instantly share code, notes, and snippets.

@jdevalk
Created November 28, 2012 08:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdevalk/4159989 to your computer and use it in GitHub Desktop.
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
<?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