]> git.mxchange.org Git - friendica.git/commitdiff
When a server isn't reachable there were timeout problems with fetching image data
authorMichael Vogel <icarus@dabo.de>
Mon, 18 Jan 2016 14:38:38 +0000 (15:38 +0100)
committerMichael Vogel <icarus@dabo.de>
Mon, 18 Jan 2016 14:38:38 +0000 (15:38 +0100)
include/Photo.php
include/network.php
mod/parse_url.php

index 30424747da82a33af4ee88c733e0b712f9967e0b..5fdd682e74e4925d40f7514b07c9f75c91a15d47 100644 (file)
@@ -792,15 +792,19 @@ function get_photo_info($url) {
 
                $filesize = strlen($img_str);
 
-               $tempfile = tempnam(get_temppath(), "cache");
+               if (function_exists("getimagesizefromstring"))
+                       $data = getimagesizefromstring($img_str);
+               else {
+                       $tempfile = tempnam(get_temppath(), "cache");
 
-               $a = get_app();
-               $stamp1 = microtime(true);
-               file_put_contents($tempfile, $img_str);
-               $a->save_timestamp($stamp1, "file");
+                       $a = get_app();
+                       $stamp1 = microtime(true);
+                       file_put_contents($tempfile, $img_str);
+                       $a->save_timestamp($stamp1, "file");
 
-               $data = getimagesize($tempfile);
-               unlink($tempfile);
+                       $data = getimagesize($tempfile);
+                       unlink($tempfile);
+               }
 
                if ($data)
                        $data["size"] = $filesize;
index ac5191b259c876306ebd8ae898b94a52cdbc0540..611f00632f4a5d507008b7d9308fa33704f77206 100644 (file)
@@ -1246,6 +1246,9 @@ function original_url($url, $depth=1, $fetchbody = false) {
 
        $a->save_timestamp($stamp1, "network");
 
+       if ($http_code == 0)
+               return($url);
+
        if ((($curl_info['http_code'] == "301") OR ($curl_info['http_code'] == "302"))
                AND (($curl_info['redirect_url'] != "") OR ($curl_info['location'] != ""))) {
                if ($curl_info['redirect_url'] != "")
index 28869b4c128d7ecd3d1f5b8436297b8b11aad5c5..2eff09d252dd318eb53136aba857bfbd362479c1 100644 (file)
@@ -71,6 +71,7 @@ function parseurl_getsiteinfo_cached($url, $no_guessing = false, $do_oembed = tr
 
 function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $count = 1) {
        require_once("include/network.php");
+       require_once("include/Photo.php");
 
        $a = get_app();
 
@@ -321,7 +322,7 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co
                        $attr[$attribute->name] = $attribute->value;
 
                        $src = completeurl($attr["src"], $url);
-                       $photodata = @getimagesize($src);
+                       $photodata = get_photo_info($src);
 
                        if (($photodata) && ($photodata[0] > 150) and ($photodata[1] > 150)) {
                                if ($photodata[0] > 300) {
@@ -338,12 +339,12 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co
                        }
 
                }
-    } else {
+    } elseif ($siteinfo["image"] != "") {
                $src = completeurl($siteinfo["image"], $url);
 
                unset($siteinfo["image"]);
 
-               $photodata = @getimagesize($src);
+               $photodata = get_photo_info($src);
 
                if (($photodata) && ($photodata[0] > 10) and ($photodata[1] > 10))
                        $siteinfo["images"][] = array("src"=>$src,