Navigation Menu

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
Expand Up @@ -76,8 +76,8 @@ function imagerotate($src_img, $angle) {
}

function pass_file_and_exit($file) {
preg_match("'^(.*)\.(gif|jpe?g|png|thm|ogv|mp4)$'i", $file, $e);
switch (strtolower($e[2])) {
$i = pathinfo($file);
switch (strtolower($i['extension'])) {
case 'jpg':
case 'jpeg':
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('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
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 'jpeg':
case 'thm':
Expand Down Expand Up @@ -204,7 +205,7 @@ function pass_file_and_exit($file) {
break;
}

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

0 comments on commit e4d97d6

Please sign in to comment.