Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

when attaching videos (eg. .flv) to a post - is it possible to query its dimensions? the problem is - i've got videos in 4:3 and 16:9 format and i need to get this information.

any ideas?


share|improve this question
Do you upload the videos yourself or do you embed them from other sites? Which sites then? –  Jan Fabry Mar 24 '11 at 19:35
add comment

3 Answers

up vote 1 down vote accepted

php-flvinfo and php-mp4info are php classes for reading flv and mp4 metadata. you could read it on the fly, or it may be possible to hook a save to get this info in the db somewhere.

share|improve this answer
add comment

I don't use videos to test. My quick guess would be to try wp_get_attachment_metadata() function.

share|improve this answer
WordPress will only save attachment metadata for images (EXIF & sizes). Looks like the need of a plugin to add support for video.. –  TheDeadMedic Mar 16 '11 at 1:09
add comment

You would need a plugin to do this. It would need to parse the video and save the meta information.

I'd recommend taking a look at this library for starters: http://code.google.com/p/flv4php/

As for implementing this as a WordPress plugin, you would need to write a function and hook it to the wp_generate_attachment_metadata filter. The code will basically look something like this:

function my_attachment_metadata($meta, $attachment_id) {
  $attachment = get_post( $attachment_id );
  $mime = get_post_mime_type( $attachment );
  $file = get_attached_file( $attachment_id );
  // use the $mime value to determine if you need to scan the file (video/x-flv)
  // use the $file for scanning for any meta data
  // store the meta data in $meta['whatever'] for each piece of info
  return $meta;

Any meta data you add to $meta and return there will be stored along with the attachment post. You can then later retrieve it, without having to reparse the file or anything, with wp_get_attachment_metadata( $attachment_id ).

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.