move html for oembeded videos in template. fix oembed discovery

This commit is contained in:
Fabio Comuni 2011-10-24 17:28:28 +02:00
parent 718a9009be
commit 75d4f33233
2 changed files with 26 additions and 16 deletions

View file

@ -16,8 +16,7 @@ function oembed_fetch_url($embedurl){
// try oembed autodiscovery // try oembed autodiscovery
$redirects = 0; $redirects = 0;
$html_text = fetch_url($embedurl, false, $redirects, 15); $html_text = fetch_url($embedurl, false, $redirects, 15);
if(! $html_text) if($html_text){
return;
$dom = @DOMDocument::loadHTML($html_text); $dom = @DOMDocument::loadHTML($html_text);
if ($dom){ if ($dom){
$xpath = new DOMXPath($dom); $xpath = new DOMXPath($dom);
@ -30,6 +29,7 @@ function oembed_fetch_url($embedurl){
$txt = fetch_url($href); $txt = fetch_url($href);
} }
} }
}
if ($txt==false || $txt==""){ if ($txt==false || $txt==""){
// try oohembed service // try oohembed service
@ -59,9 +59,15 @@ function oembed_format_object($j){
/*$tw = (isset($j->thumbnail_width)) ? $j->thumbnail_width:200; /*$tw = (isset($j->thumbnail_width)) ? $j->thumbnail_width:200;
$th = (isset($j->thumbnail_height)) ? $j->thumbnail_height:180;*/ $th = (isset($j->thumbnail_height)) ? $j->thumbnail_height:180;*/
$tw=150; $th=120; $tw=150; $th=120;
$ret.= "<a href='".$embedurl."' onclick='this.innerHTML=unescape(\"".urlencode($j->html)."\").replace(/\+/g,\" \"); return false;' style='float:left; margin: 1em; '>"; $tpl=get_markup_template('oembed_video.tpl');
$ret.= "<img width='$tw' height='$th' src='".$j->thumbnail_url."'>"; $ret.=replace_macros($tpl, array(
$ret.= "</a>"; '$embedurl'=>$embedurl,
'$escapedhtml'=>urlencode($j->html),
'$tw'=>$tw,
'$th'=>$th,
'$turl'=>$j->thumbnail_url,
));
} else { } else {
$ret=$j->html; $ret=$j->html;
} }

4
view/oembed_video.tpl Normal file
View file

@ -0,0 +1,4 @@
<a href='$embedurl' onclick='this.innerHTML=unescape("$escapedhtml").replace(/\+/g," "); return false;' style='float:left; margin: 1em; position: relative;'>
<img width='$tw' height='$th' src='$turl' >
<div style='position: absolute; top: 0px; left: 0px; width: $twpx; height: $thpx; background: url(images/icons/48/play.png) no-repeat center center;'></div>
</a>