View Single Post
Old 10-14-2013, 06:49 PM  
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,426
Quote:
Originally Posted by CyberSEO View Post
Sure I can. Which exactly XML feed you do you want to parse? Some feeds have the <link> tags, others do contain the video URL in <video> or <clip> sections etc. I need to see your feed to give you the proper code.
he is using it for youtube videos, so would need either just the youtube id or the full url (not embed) just the url.

Code:
if ($post ['post_content'] == '') {
    $post ['post_content'] = $post ['post_excerpt'];
}
$post ['post_content'] = html_entity_decode($post ['post_content']);
// assign preferred width and height of youtube video
$width = 500;
$height =350;
// extract image thumbnail
preg_match ( "/<img(.*?)src=[\'\"](.+?)[\'\"](.*?)>/s", $post ['post_content'], $matches );
$post ['custom_fields'] ['thumb'] = $matches [2];
// extract youtube clip id
preg_match ( "/www.youtube.com\/watch\?v=(.*?)[&|\"]/s", $post ['post_content'], $matches );
$clip_id = $matches [1];
// create youtube player code and insert the extracted clip id there
$video = "<iframe width=\"$width\" height=\"$height\" src=\"https://youtube.com/embed/$clip_id\" frameborder=\"0\" allowfullscreen></iframe>";
// extract the clip description
preg_match ( "/<span>(.*?)<\/span>/s", $post ['post_content'], $matches );
$post ['post_content'] = "<p>" . $video . "</p>\n<p>" . $matches [1] . "</p>\n";
$post ['post_excerpt'] = '';
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote