Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Kyle Gilman

    (@kylegilman)

    Sure. And you don’t need to use my plugin to do it. This information is actually built in to WordPress for most video formats since version 3.6. It’s stored in the _wp_attachment_metadata array. You’ll probably want to use the length_formatted key. Here’s an example assuming you have the video attachment ID stored in a variable $attachment_ID :

    $video_meta = get_post_meta( $attachment_ID, '_wp_attachment_metadata', true );
    echo $video_meta['length_formatted'];
    Thread Starter James Morton

    (@stylishjm)

    Perfect, I’ll give that a go.
    Thanks

    Plugin Author Kyle Gilman

    (@kylegilman)

    It doesn’t matter much, but I think it would also work with the function wp_get_attachment_metadata

    $video_meta = wp_get_attachment_metadata( $attachment_ID );

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Echo video length?’ is closed to new replies.