X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fparse_url.php;h=400c248e05d5fd5961f80842449c315caf545f74;hb=5f1ef732e05c79584e6ea1cdb14360a7dd388a9d;hp=ea05055f0cefc69b461c29b5e009786320bcc2b8;hpb=6d0f0e62733d4e2088631c8e4ab44631d9e60548;p=friendica.git diff --git a/mod/parse_url.php b/mod/parse_url.php index ea05055f0c..400c248e05 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -36,6 +36,9 @@ function completeurl($url, $scheme) { if ($schemearr["port"] != "") $complete .= ":".$schemearr["port"]; + if(strpos($urlarr['path'],'/') !== 0) + $complete .= '/'; + $complete .= $urlarr["path"]; if ($urlarr["query"] != "") @@ -149,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; @@ -173,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]); @@ -236,6 +239,9 @@ function parse_url_content(&$a) { if(local_user() && intval(get_pconfig(local_user(),'system','plaintext'))) $textmode = true; + if(local_user() && (! feature_enabled(local_user(),'richtext'))) + $textmode = true; + //if($textmode) $br = (($textmode) ? "\n" : '
'); @@ -304,16 +310,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)