summaryrefslogtreecommitdiff
path: root/plugins/GNUsocialPhotos/actions/photos.php
diff options
context:
space:
mode:
authorIan Denhardt <ian@zenhack.net>2010-08-04 12:03:34 -0400
committerIan Denhardt <ian@zenhack.net>2010-08-04 12:03:34 -0400
commit33bce7227f73d0de43a85c23c6268f280c0d1114 (patch)
treed530f1a44fab221b123df35a4285814d4c6b0b95 /plugins/GNUsocialPhotos/actions/photos.php
parent78d9edd431d7f0f2bfbd47112edbf72e37c13bc6 (diff)
slight cleanup, we now get the image type from getimagesize(), rather than finding it ourselves.
Diffstat (limited to 'plugins/GNUsocialPhotos/actions/photos.php')
-rw-r--r--plugins/GNUsocialPhotos/actions/photos.php21
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];