image_type_to_extension()
will work because it is not based on the file extension, it read the mime type of the file, you can achieve the same result by using finfo: http://www.php.net/manual/en/function.finfo-file.php
And now it makes perfect sense, I wasn't sure about some of those methods, your explanation clarifies my doubts. Try this:
# last part of getImagefile() ...
} else {
$file = $this->params['images_dir'].$image;
//
// if the image is a regular file
//
if(is_file($file.'.jpg') || is_file($file.'.GIF'))
{
$finfo = finfo_open(FILEINFO_MIME_TYPE);
switch(finfo_file($finfo, $file))
{
case 'image/jpeg':
$file = $file . '.jpg';
break;
case 'image/gif':
$file = $file . '.GIF';
break;
}
}
}
return $file;
}
It's just an example but it should work fine. Just pay attention to uppercase, if you're using a linux box image.GIF
will be considered different from image.gif
. In practice my suggestion is the same solution of yours, the only difference is that I'm not applying $this->params['images_dir']
and DIR_IMAGE
togheter. Have you checked the logs of the server to see if there are undefined paths?