From: Hypolite Petovan Date: Sun, 5 Aug 2018 14:02:25 +0000 (+0200) Subject: [twitter] Fix Read Error with exif_imagetype() X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=bda506fd2ec699463bc1421a456c3001c160f51a;p=friendica-addons.git [twitter] Fix Read Error with exif_imagetype() --- diff --git a/twitter/twitter.php b/twitter/twitter.php index ab7697bb..9de7b47d 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -1183,7 +1183,14 @@ function twitter_expand_entities(App $a, $body, $item, $picture) $tempfile = tempnam(get_temppath(), "cache"); file_put_contents($tempfile, $img_str); - $mime = image_type_to_mime_type(exif_imagetype($tempfile)); + + // See http://php.net/manual/en/function.exif-imagetype.php#79283 + if (filesize($tempfile) > 11) { + $mime = image_type_to_mime_type(exif_imagetype($tempfile)); + } else { + $mime = false; + } + unlink($tempfile); if (substr($mime, 0, 6) == "image/") {