]> git.mxchange.org Git - friendica.git/blobdiff - include/oembed.php
Merge pull request #806 from maase2/patch-6
[friendica.git] / include / oembed.php
index 6fc4c5371709bcc96355a2c4e81f2e73ccf2d73d..bc127b5c3515f61cd061bcb63f9fa2710dc2f426 100755 (executable)
@@ -74,9 +74,10 @@ function oembed_format_object($j){
        switch ($j->type) {
                case "video": {
                        if (isset($j->thumbnail_url)) {
-                               $tw = (isset($j->thumbnail_width)) ? $j->thumbnail_width:200;
-                               $th = (isset($j->thumbnail_height)) ? $j->thumbnail_height:180;
-                               $tr = $tw/$th;
+                               $tw = (isset($j->thumbnail_width) && intval($j->thumbnail_width)) ? $j->thumbnail_width:200;
+                               $th = (isset($j->thumbnail_height) && intval($j->thumbnail_height)) ? $j->thumbnail_height:180;
+                               // make sure we don't attempt divide by zero, fallback is a 1:1 ratio
+                               $tr = (($th) ? $tw/$th : 1);
                                
                                $th=120; $tw = $th*$tr;
                                $tpl=get_markup_template('oembed_video.tpl');
@@ -116,7 +117,7 @@ function oembed_format_object($j){
                if (isset($j->provider_name)) $ret.=" on ".$j->provider_name;
        } else {
                // add <a> for html2bbcode conversion
-               $ret .= "<a href='$embedurl' rel='oembed'/>";
+               $ret .= "<a href='$embedurl' rel='oembed'></a>";
        }
        $ret.="<br style='clear:left'></span>";
        return  mb_convert_encoding($ret, 'HTML-ENTITIES', mb_detect_encoding($ret));