X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fparse_url.php;h=9adee8f65cd8d7d9c261f6d16522ea2ed0859cd9;hb=6aa45fb9cc2569f99b550003ee3f98916754dd0a;hp=e66db37fed20e3f99ba58a9bb7d56bc39d936893;hpb=3968dc932fe527fe7c370fa52c084bc693d8d316;p=friendica.git diff --git a/mod/parse_url.php b/mod/parse_url.php index e66db37fed..9adee8f65c 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -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 .= '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 .= 'photo
'; + $total_images ++; + if($max_images && $max_images >= $total_images) + break; } + } if(strlen($text)) { if($textmode)