Quote:
Originally Posted by CyberSEO
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'] = '';