From 33bce7227f73d0de43a85c23c6268f280c0d1114 Mon Sep 17 00:00:00 2001 From: Ian Denhardt Date: Wed, 4 Aug 2010 12:03:34 -0400 Subject: [PATCH] slight cleanup, we now get the image type from getimagesize(), rather than finding it ourselves. --- plugins/GNUsocialPhotos/actions/photos.php | 29 ++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/plugins/GNUsocialPhotos/actions/photos.php b/plugins/GNUsocialPhotos/actions/photos.php index 4a927782aa..aef2478b17 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') { - $image_src = imagecreatefromjpeg(INSTALLDIR . '/file/' . $filename); - $image_type = IMAGETYPE_JPEG; - } else if(substr($filename, -4) == '.png') { - $image_src = imagecreatefrompng(INSTALLDIR . '/file/' . $filename); - $image_type = IMAGETYPE_PNG; - } else if(substr($filename, -4) == '.gif') { - $image_src = imagecreatefromgif(INSTALLDIR . '/file/' . $filename); - $image_type = IMAGETYPE_GIF; - } else { - return false; - } - $size_src = getimagesize(INSTALLDIR . '/file/' . $filename); + $image_type = $size_src[2]; + + switch($image_type) { + case IMAGETYPE_JPEG: + $image_src = imagecreatefromjpeg(INSTALLDIR . '/file/' . $filename); + break; + case IMAGETYPE_PNG: + $image_src = imagecreatefrompng(INSTALLDIR . '/file/' . $filename); + break; + case IMAGETYPE_GIF: + $image_src = imagecreatefromgif(INSTALLDIR . '/file/' . $filename); + break; + default: + return false; + } + $width_src = $size_src[0]; $height_src = $size_src[1];