]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #1545 from annando/1503-load-issues
authorTobias Diekershoff <tobias.diekershoff@gmx.net>
Sun, 3 May 2015 07:15:54 +0000 (09:15 +0200)
committerTobias Diekershoff <tobias.diekershoff@gmx.net>
Sun, 3 May 2015 07:15:54 +0000 (09:15 +0200)
Value for maximum load until the frontend quits service

include/bbcode.php
include/oembed.php
js/main.js

index ef791d9e7cfa3024926852211f7f5e020f7f0556..1eac012c3e7c92d07a6812a03939de3683fd16dc 100644 (file)
@@ -4,7 +4,7 @@ require_once('include/event.php');
 
 function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
        $Text = preg_replace_callback("/(.*?)\[attachment(.*?)\](.*?)\[\/attachment\]/ism",
-               function ($match) use ($plaintext){
+               function ($match) use ($plaintext, $tryoembed){
 
                        $attributes = $match[2];
 
@@ -83,14 +83,18 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
                                else
                                        $oembed = $bookmark[0];
 
-                               if (($image != "") AND !strstr(strtolower($oembed), "<img "))
-                                       $text .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a><br />', $url, $image, $title);
-                               elseif (($preview != "") AND !strstr(strtolower($oembed), "<img "))
-                                       $text .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-preview" /></a><br />', $url, $preview, $title);
+                               if (strstr(strtolower($oembed), "<iframe "))
+                                       $text = $oembed;
+                               else {
+                                       if (($image != "") AND !strstr(strtolower($oembed), "<img "))
+                                               $text .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a><br />', $url, $image, $title);
+                                       elseif (($preview != "") AND !strstr(strtolower($oembed), "<img "))
+                                               $text .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-preview" /></a><br />', $url, $preview, $title);
 
-                               $text .= $oembed;
+                                       $text .= $oembed;
 
-                               $text .= sprintf('<blockquote>%s</blockquote></span>', trim($match[3]));
+                                       $text .= sprintf('<blockquote>%s</blockquote></span>', trim($match[3]));
+                               }
                        }
 
                        return($match[1].$text);
index a793bd8006d754a242dd791a6a1952a684930622..6fc981729944a29323b969bb6fcdf78ba1de1b4c 100755 (executable)
@@ -199,10 +199,15 @@ function oembed_format_object($j){
 }
 
 function oembed_iframe($src,$width,$height) {
+
        if(! $width || strstr($width,'%'))
                $width = '640';
-       if(! $height || strstr($height,'%'))
+       if(! $height || strstr($height,'%')) {
                $height = '300';
+               $resize = 'onload="resizeIframe(this);"';
+       } else
+               $resize = '';
+
        // try and leave some room for the description line.
        $height = intval($height) + 80;
        $width  = intval($width) + 40;
@@ -210,7 +215,7 @@ function oembed_iframe($src,$width,$height) {
        $a = get_app();
 
        $s = $a->get_baseurl()."/oembed/".base64url_encode($src);
-       return '<iframe class="embed_rich" height="' . $height . '" width="' . $width . '" src="' . $s . '" frameborder="no" >' . t('Embedded content') . '</iframe>';
+       return '<iframe '.$resize.' class="embed_rich" height="'.$height.'" width="'.$width.'" src="'.$s.'" frameborder="no">'.t('Embedded content').'</iframe>';
 
 }
 
index d7381c96a474e47671f01bcdb727000be8a6b233..25029c1b055c536e401152a6a929d71a85cfa9cc 100644 (file)
@@ -1,3 +1,7 @@
+  function resizeIframe(obj) {
+    obj.style.height = 0;
+    obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
+  }
 
   function openClose(theID) {
     if(document.getElementById(theID).style.display == "block") {