Skip to content

Commit

Permalink
Convert extension retrieval to pathinfo().
Browse files Browse the repository at this point in the history
  • Loading branch information
sofar committed Oct 8, 2012
1 parent 18a7bb0 commit e4d97d6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions image.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ function imagerotate($src_img, $angle) {
} }


function pass_file_and_exit($file) { function pass_file_and_exit($file) {
preg_match("'^(.*)\.(gif|jpe?g|png|thm|ogv|mp4)$'i", $file, $e); $i = pathinfo($file);
switch (strtolower($e[2])) { switch (strtolower($i['extension'])) {
case 'jpg': case 'jpg':
case 'jpeg': case 'jpeg':
case 'thm': case 'thm':
Expand Down Expand Up @@ -134,7 +134,8 @@ function pass_file_and_exit($file) {
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($obj)).' GMT', true, 200); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($obj)).' GMT', true, 200);
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (80640 * 180)) . ' GMT', true, 200); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (80640 * 180)) . ' GMT', true, 200);


preg_match("'^(.*)\.(gif|jpe?g|png|thm)$'i", $image, $ext); $i = pathinfo($image);
$ext = strtolower($i['extension']);


# fetch the (already rotated) cached file if present # fetch the (already rotated) cached file if present
if (file_exists($cache_file)) if (file_exists($cache_file))
Expand All @@ -151,7 +152,7 @@ function pass_file_and_exit($file) {
} }
} }


switch (strtolower($ext[2])) { switch ($ext) {
case 'jpg': case 'jpg':
case 'jpeg': case 'jpeg':
case 'thm': case 'thm':
Expand Down Expand Up @@ -204,7 +205,7 @@ function pass_file_and_exit($file) {
break; break;
} }


switch (strtolower($ext[2])) { switch ($ext) {
case 'thm' : case 'thm' :
imagejpeg($save); imagejpeg($save);
break; break;
Expand Down

0 comments on commit e4d97d6

Please sign in to comment.