Get rid of Auto Enclosure of Media Files from Wordpress Feed
Post date: Nov 16, 2010 5:43:13 PM
When you add any media files link in wordpress page/post content (mp3, asf, wmv, avi etc), it creates a automatic meta key(Custom Fields) in the post called "enclosed" with value as actual path of that media file. Furthermore, the Website feed(RSS) embeds the enclosed media as a link "Download Now" or "Filname" linked to the actual media file.
It creates problem when your website have regular posts with media links for eg. podcast, background music etc. hence the feed subscriber get a download link in their feed subscription.
Just paste the following lines of codes within your themes functions.php file, and then, say goodby to automatic enclosures.
add_filter( 'do_enclose', 'delete_enclosure' );
add_filter( 'rss_enclosure', 'delete_enclosure' );
add_filter( 'atom_enclosure', 'delete_enclosure' );
What it does is, override the function do_enclose() in /wp-includes/functions.php(line 1164 - Worpress v3.01) and return blank string hence no enclosure code is executed.