]> git.mxchange.org Git - friendica.git/blobdiff - mod/parse_url.php
admin: Don't allow to block or delete site admin in users admin page. fix bug 471
[friendica.git] / mod / parse_url.php
index e66db37fed20e3f99ba58a9bb7d56bc39d936893..9adee8f65cd8d7d9c261f6d16522ea2ed0859cd9 100644 (file)
@@ -152,17 +152,17 @@ function parseurl_getsiteinfo($url) {
        }
 
        if ($siteinfo["image"] == "") {
-                $list = $xpath->query("//img[@src]");
-                foreach ($list as $node) {
-                        $attr = array();
-                        if ($node->attributes->length)
-                                foreach ($node->attributes as $attribute)
-                                        $attr[$attribute->name] = $attribute->value;
+            $list = $xpath->query("//img[@src]");
+            foreach ($list as $node) {
+                $attr = array();
+                if ($node->attributes->length)
+                    foreach ($node->attributes as $attribute)
+                        $attr[$attribute->name] = $attribute->value;
 
                        $src = completeurl($attr["src"], $url);
-                       $photodata = getimagesize($src);
+                       $photodata = @getimagesize($src);
 
-                       if (($photodata[0] > 150) and ($photodata[1] > 150)) {
+                       if (($photodata) && ($photodata[0] > 150) and ($photodata[1] > 150)) {
                                if ($photodata[0] > 300) {
                                        $photodata[1] = round($photodata[1] * (300 / $photodata[0]));
                                        $photodata[0] = 300;
@@ -176,15 +176,15 @@ function parseurl_getsiteinfo($url) {
                                                                "height"=>$photodata[1]);
                        }
 
-                }
-        } else {
+               }
+    } else {
                $src = completeurl($siteinfo["image"], $url);
 
                unset($siteinfo["image"]);
 
-               $photodata = getimagesize($src);
+               $photodata = @getimagesize($src);
 
-               if (($photodata[0] > 10) and ($photodata[1] > 10))
+               if (($photodata) && ($photodata[0] > 10) and ($photodata[1] > 10))
                        $siteinfo["images"][] = array("src"=>$src,
                                                        "width"=>$photodata[0],
                                                        "height"=>$photodata[1]);
@@ -307,16 +307,26 @@ function parse_url_content(&$a) {
 
        $image = "";
 
-        if(sizeof($siteinfo["images"]) > 0){
-            /*
-              Execute below code only if image is present in siteinfo
-             */
-            foreach ($siteinfo["images"] as $imagedata)
-               if($textmode)
-                    $image .= '[img='.$imagedata["width"].'x'.$imagedata["height"].']'.$imagedata["src"].'[/img]';
+       if(sizeof($siteinfo["images"]) > 0){
+               /* Execute below code only if image is present in siteinfo */
+
+               $total_images = 0;
+               $max_images = get_config('system','max_bookmark_images');
+               if($max_images === false)
+                       $max_images = 2;
                else
-                    $image .= '<img height="'.$imagedata["height"].'" width="'.$imagedata["width"].'" src="'.$imagedata["src"].'" alt="photo" />';
+                       $max_images = intval($max_images);
+
+               foreach ($siteinfo["images"] as $imagedata) {
+                       if($textmode)
+                               $image .= '[img='.$imagedata["width"].'x'.$imagedata["height"].']'.$imagedata["src"].'[/img]' . "\n";
+                       else
+                               $image .= '<img height="'.$imagedata["height"].'" width="'.$imagedata["width"].'" src="'.$imagedata["src"].'" alt="photo" /><br />';
+                       $total_images ++;
+                       if($max_images && $max_images >= $total_images)
+                               break;
         }
+       }
 
        if(strlen($text)) {
                if($textmode)