From: Ian Denhardt Date: Wed, 4 Aug 2010 16:03:34 +0000 (-0400) Subject: slight cleanup, we now get the image type from getimagesize(), rather than finding... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=33bce7227f73d0de43a85c23c6268f280c0d1114;p=quix0rs-gnu-social.git slight cleanup, we now get the image type from getimagesize(), rather than finding it ourselves. --- 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') { + $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];