diff options
-rw-r--r-- | plugins/GNUsocialPhotos/actions/photos.php | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/plugins/GNUsocialPhotos/actions/photos.php b/plugins/GNUsocialPhotos/actions/photos.php index 4a927782a..aef2478b1 100644 --- a/plugins/GNUsocialPhotos/actions/photos.php +++ b/plugins/GNUsocialPhotos/actions/photos.php @@ -113,20 +113,23 @@ class PhotosAction extends Action $height_dest = 192; $width_dest = 256; - if (substr($filename, -4) == '.jpg' || substr($filename, -5) == '.jpeg') { + $size_src = getimagesize(INSTALLDIR . '/file/' . $filename); + $image_type = $size_src[2]; + + switch($image_type) { + case IMAGETYPE_JPEG: $image_src = imagecreatefromjpeg(INSTALLDIR . '/file/' . $filename); - $image_type = IMAGETYPE_JPEG; - } else if(substr($filename, -4) == '.png') { + break; + case IMAGETYPE_PNG: $image_src = imagecreatefrompng(INSTALLDIR . '/file/' . $filename); - $image_type = IMAGETYPE_PNG; - } else if(substr($filename, -4) == '.gif') { + break; + case IMAGETYPE_GIF: $image_src = imagecreatefromgif(INSTALLDIR . '/file/' . $filename); - $image_type = IMAGETYPE_GIF; - } else { + break; + default: return false; - } + } - $size_src = getimagesize(INSTALLDIR . '/file/' . $filename); $width_src = $size_src[0]; $height_src = $size_src[1]; |