diff options
author | mrjive <mrjive@mrjive.it> | 2016-02-03 22:46:54 +0100 |
---|---|---|
committer | mrjive <mrjive@mrjive.it> | 2016-02-03 22:46:54 +0100 |
commit | e527a52f6a123b695775a24fdeb64d0a5ab00df9 (patch) | |
tree | 7f72feb65e8f8790d6d80f631d1e608bfed1dd48 /include/oembed.php | |
parent | 337735094b944fd31ed96e36c869227a0d63e5d1 (diff) | |
parent | a7ed50ecd4b4defbc1d5fdf0bb4fd7d65d08a0fd (diff) | |
download | volse-hubzilla-e527a52f6a123b695775a24fdeb64d0a5ab00df9.tar.gz volse-hubzilla-e527a52f6a123b695775a24fdeb64d0a5ab00df9.tar.bz2 volse-hubzilla-e527a52f6a123b695775a24fdeb64d0a5ab00df9.zip |
Merge pull request #21 from redmatrix/master
updating from original codebase
Diffstat (limited to 'include/oembed.php')
-rwxr-xr-x | include/oembed.php | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/include/oembed.php b/include/oembed.php index 2d3e0d3f9..7c577b6c2 100755 --- a/include/oembed.php +++ b/include/oembed.php @@ -53,6 +53,10 @@ function oembed_fetch_url($embedurl){ $a = get_app(); + $embedurl = str_replace('&','&', $embedurl); + +// logger('fetch: ' . $embedurl); + $txt = Cache::get($a->videowidth . $embedurl); if(strstr($txt,'youtu') && strstr(z_root(),'https:')) { @@ -120,20 +124,29 @@ function oembed_fetch_url($embedurl){ if ($txt[0]!="{") $txt='{"type":"error"}'; //save in cache - Cache::set($a->videowidth . $embedurl,$txt); + + if(! get_config('system','oembed_cache_disable')) + Cache::set($a->videowidth . $embedurl,$txt); } $j = json_decode($txt); $j->embedurl = $embedurl; + +// logger('fetch return: ' . print_r($j,true)); + return $j; + + } function oembed_format_object($j){ $a = get_app(); $embedurl = $j->embedurl; +// logger('format: ' . print_r($j,true)); + $jhtml = oembed_iframe($j->embedurl,(isset($j->width) ? $j->width : null), (isset($j->height) ? $j->height : null)); $ret="<span class='oembed ".$j->type."'>"; @@ -191,23 +204,29 @@ function oembed_format_object($j){ // add link to source if not present in "rich" type if ( $j->type!='rich' || !strpos($j->html,$embedurl) ){ $embedlink = (isset($j->title))?$j->title:$embedurl; - $ret .= '<span class="bookmark-identifier">#^</span>' . "<a href='$embedurl' rel='oembed'>$embedlink</a>"; - $ret .= "<br>"; + $ret .= '<br /><span class="bookmark-identifier">#^</span>' . "<a href='$embedurl' rel='oembed'>$embedlink</a>"; + $ret .= "<br />"; if (isset($j->author_name)) $ret.=" by ".$j->author_name; if (isset($j->provider_name)) $ret.=" on ".$j->provider_name; } else { // add <a> for html2bbcode conversion - $ret .= "<a href='$embedurl' rel='oembed'/>"; + $ret .= "<br /><a href='$embedurl' rel='oembed'>$embedurl</a>"; } $ret.="<br style='clear:left'></span>"; return mb_convert_encoding($ret, 'HTML-ENTITIES', mb_detect_encoding($ret)); } function oembed_iframe($src,$width,$height) { - if(! $width || strstr($width,'%')) + $scroll = ' scrolling="no" '; + if(! $width || strstr($width,'%')) { $width = '640'; - if(! $height || strstr($height,'%')) + $scroll = ' scrolling="auto" '; + } + if(! $height || strstr($height,'%')) { $height = '300'; + $scroll = ' scrolling="auto" '; + } + // try and leave some room for the description line. $height = intval($height) + 80; $width = intval($width) + 40; @@ -216,7 +235,7 @@ function oembed_iframe($src,$width,$height) { // Make sure any children are sandboxed within their own iframe. - return '<iframe height="' . $height . '" width="' . $width . '" src="' . $s . '" frameborder="no" >' + return '<iframe ' . $scroll . 'height="' . $height . '" width="' . $width . '" src="' . $s . '" frameborder="no" >' . t('Embedded content') . '</iframe>'; } |