RSS audio enclosures have length of zero (podcast duration is missing)

I have had success at creating an RSS feed with enclosures containing episodes of my podcast by simply creating a post and inserting an mp3 file from my media library into it via the robust Add Media functionality of the post editor. However, I have found that the RSS feed created from these posts includes an enclosure for each mp3 file with its length attribute set to zero:

<enclosure url="http://example.com/wp-content/uploads/2020/05/myfile.mp3" length="0" type="audio/mpeg" />

How can I set the length attribute of the enclosure so that it is accurate?

I am not interested in changing the format of my posts, so any plugin-based solution should not require a significantly different workflow when posting.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

The enclosure tag will implement via the function rss_enclosure. This function has the filter hook rss_enclosure. So you can change the result via this hook.

Here is a longer post about the how-to for audio files, this should help you.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x