Quantcast
Channel: Topic Tag: xml | WordPress.org
Viewing all articles
Browse latest Browse all 3201

Aaron Bazinet on "How do I get MP3 audio duration and file size for podcast RSS feed?"

$
0
0

I got some help on the Types plugin forums on the file size. Here’s what I got:

<?php
  global $wpdb;
    $fileurl = types_render_field('pod-audio', array('raw'=>'true'));
    $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts}
    WHERE post_type = 'attachment' AND guid=%s", $fileurl ));
    $filesize = filesize( get_attached_file( $attachment_id ) );
?>
<enclosure url="<?php echo $fileurl; ?>" length="<?php echo $filesize; ?>" type="audio/mpeg" />
<guid><?php echo $fileurl; ?></guid>

I still need a way to get duration. You’d think with files uploaded through WP’s uploader that WP would pull as much metadata in as possible, and duration seems like a key piece.


Viewing all articles
Browse latest Browse all 3201

Trending Articles