Current state: I'm parsing XML feeds into the front end and/or the back end (Admin UI), but not into the DB. Inside those feeds i place mp3- and video content, currently only as plain text (no link, no player).

Future goal: I want to change the above behavior so visitors can watch/listen to video/audio content.

What I'm searching for: builtin (wp core) function(s) that load a (wp core) player for audio and/or video files in the feed. What I'm not searching for: A regular expression/regex to replace the current text (link).

The solution should be independent from any plugins, themes or any other third party code.

Edit: Shortly ma question, maybe you understand my problem easier

Is there a way to see \'enclosures\' from RSS feeds? I would like to use the images as thumbnails and view a player for video and audio enclosures. Here is an example feed item with enclosure...

    <title>New Ferrari FF video</title>

    <description>Ferrari releases a new, action-packed and undisguised video of its FF supercar. Video and new pictures here</description>
    <pubDate>Fri, 25 Feb 2011 15:04:58 +0000</pubDate>
    <enclosure url="http://www.evo.co.uk/images/front_picture_library_UK/dir_853/car_photo_426559_23.jpg" length="5420" type="image/jpeg"/>
  • Maybe I'm just reading wrong, but I don't at all get what you're trying to ask... Jan 13, 2011 at 19:51
  • Sorry, my english is bad. Short: I will replace the enclosure of audio and video with a player; for play audios/videos on the website after read xml.
    – bueltge
    Jan 14, 2011 at 8:58
  • Are you asking alter some data (via xml) that you are importing into WordPress so that any audio/video files that are enclosed in the xml file are automatically replaced by code allowing end-users to play the files rather than download them?
    – Manzabar
    Feb 14, 2011 at 22:41
  • 1
    @bueltge: Do you currently use the SimplePie class to display the feed? Because this already contains support for getting enclosure data from an item, you won't need an extra XML parser for that. Now is your question how to get the enclosure information or how to show the player? Can you add the code you currently use to display the feed in your site?
    – Jan Fabry
    Feb 15, 2011 at 13:07
  • 1
    @bueltge: WordPress doesn't include a media player. Well, it used to, but it will be removed in 3.1 because the original license is unclear and the sources cannot be found. So you'll have to find a hosted player that can play arbitrary files, to embed it in your site.
    – Jan Fabry
    Feb 18, 2011 at 12:13

3 Answers 3


I believe part of what you're looking for is the WP_Embed class defined in wp-includes/media.php. It implements a framework for automatically replacing urls with the output of embed handlers. I'm afraid you'll have to do the deeper research yourself (this was apparently introduces in 2.9.0, so documentation might still be thin).

I doubt Wordpress core comes with a player solution or will ever do so. It would seem it installs a single default embed handler for googlevideo urls. For anything else you'll have to write and register your own embed handler and if you want to host the files and player yourself, you'll either need a 3rd party player (plugin) or rely on HTML5 video/audio tags.

Ahh...and the WP_Embed class seems to get added as a callback to the 'the_content' filters by default, so you shouldn't need to do so manually. At least that's what it looks like here. ;-)

IF on the other hand you are not trying to replace URLs pointing to your media files, but rather complete tag enclosures like <video></video> or <embed></embed> and so on, then you'll have to rely on regex or write your PHP XML manipulation functions, as i'm pretty sure Wordpress doesn't natively come with functions to do something like that.

You could, however, combine that with above, making your job a bit easier, by regex-erasing everything within those tags and the tags themselves and only leaving the url. If you regsiter the filter callback that does that with a higher priority than 10 on the 'the_content' filter hook, the WP_Embed filter callback will then react on these URLs and you can do the rest using the WP_Embed framework.

  • thanks for reply. I have search in this class and the wp_embed works well with the url and oEmbed interface. But i will see also in the core of WordPress for an solution. My opinio for this questian was: maybe someone has to experience and i can use this experience.
    – bueltge
    Feb 16, 2011 at 7:43

If your trying to replace XML Data I think the best way would be to use the XMLParser functions or the Simple XML Functions.



I dont have any examples at hand but there should be plenty around on the web.

Answer to comment Simplepie seems to be able to edit contents before output like this: http://simplepie.org/wiki/tutorial/how_to_edit_part_of_the_feed_before_parsing_it.

If your video is an url from the major video streamers that use oEmbed you might be able to use http://codex.wordpress.org/oEmbed this to get the video players and inject these into the simplepie stream, but this is pure speculation on my part. I havent worked with either classes.

  • it is not a my problem to read the xml, but i will replace the enclosure of audio and video with a player; for play audios/videos on the website after read xml. Current i read the xml with the simplepie of the WordPress core, works fine.
    – bueltge
    Jan 14, 2011 at 8:57

If the services hosting the original media don't support OEmbed, then you're going to have to manually install your own players. There's no built-in function that will give you media players that easily. If they do support OEmbed, then all you need to do is wrap your links in [embed] shortcodes with a content filter, and maybe add a filter to whitelist the OEmbed services.

  • yes, i know this solution; but it is not possible to add all oEmbed-services, they WordPress knows, to parse the feed and when its an services, like youtube, inside the feed is, than replace this with a player? The feeds are changed, the plugin was used from many people on many sites and all ask for an soltuion to replace the enclosures with a player. It is not possible for me to add all solutions for all services, i cant all services. Thanks for you reply
    – bueltge
    Feb 28, 2011 at 20:48
  • maybe it is possible i add a hook after parsing feed, like the_content on WP and add the folow functions? add_filter( 'my_hook', array( $wp_embed, 'run_shortcode' ), 8 ); add_filter( 'my_hook', array( $wp_embed, 'autoembed'), 8 );
    – bueltge
    Mar 1, 2011 at 6:39
  • 1
    You could run into difficulties with this if the oEmbed service recognizes the URL of the page containing the media, but not the URL of the media file. Take YouTube: the oEmbed recognizes http://(www\.)?youtube.com/watch.*, but this will not match the actual media file URL.
    – Jan Fabry
    Mar 1, 2011 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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