diff options
author | zotlabs <mike@macgirvin.com> | 2017-06-25 18:07:07 -0700 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2017-06-25 18:07:07 -0700 |
commit | 07d6472eea377a9be7e35cca823307382a43df46 (patch) | |
tree | 4a880c31142fc77fae6a4298204c3ce6861cf84b /include/photo | |
parent | 6c771f84cedc71e7ffeecebe3e2fd7f912de3e7b (diff) | |
download | volse-hubzilla-07d6472eea377a9be7e35cca823307382a43df46.tar.gz volse-hubzilla-07d6472eea377a9be7e35cca823307382a43df46.tar.bz2 volse-hubzilla-07d6472eea377a9be7e35cca823307382a43df46.zip |
mastodon reshares can be either posts or comments; silence warning from guess_image_type when handed a URL to a non-existent resource.
Diffstat (limited to 'include/photo')
-rw-r--r-- | include/photo/photo_driver.php | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index eb61578e1..9d27ef96e 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -495,12 +495,22 @@ function guess_image_type($filename, $headers = '') { } } - if(is_null($type)) { + if(is_null($type) && (strpos($filename,'http:') === false)) { $size = getimagesize($filename); $ph = photo_factory(''); $types = $ph->supportedTypes(); $type = ((array_key_exists($size['mime'], $types)) ? $size['mime'] : 'image/jpeg'); } + if(is_null($type)) { + if(strpos(strtolower($filename),'jpg') !== false) + $type = 'image/jpeg'; + elseif(strpos(strtolower($filename),'jpeg') !== false) + $type = 'image/jpeg'; + elseif(strpos(strtolower($filename),'gif') !== false) + $type = 'image/gif'; + elseif(strpos(strtolower($filename),'png') !== false) + $type = 'image/png'; + } } logger('Photo: guess_image_type: type = ' . $type, LOGGER_DEBUG); |