
Originally Posted by
carlwhat
i think i have spoken about this before.... unfortunately my memory is not what it once was....
while certain uses of '@' to suppress error messages are possibly worth wild, the inordinate amount of them in this plugin makes it rather frustrating.
the bmz_image_handler.class.php file will suppress error messages and cause a script to fail. specifically the functions:
imagecreatefromgif
imagecreatefrompng
imagecreatefromjpeg
i'm not sure how many others have clients who do not know the difference between a jpg and a png; but mine don't and will use whatever extension they feel like. so now you have a script failing and no error messages.... kind of a pain....
in addition, there is a php function: exif_imagetype() which will determine the file type. now i know i could make some changes and submit a new version, but prior to doing that, i'm curious if other people have this same problem.
in the interest of others who might have this problem, this corrected code works for me. it eliminates some functionality, but it removes the troubleshooting when someone uploads an image with the wrong file type. i suppose one could correct the filetype, but i think that might be a bunch more work.
Code:
function load_imageGD($src_name) {
// create an image of the given filetype
$file_ext = substr($src_name, strrpos($src_name, '.'));
$image_type = exif_imagetype($src_name);
switch (strtolower($file_ext)) {
case '.gif':
if(!function_exists("imagecreatefromgif")) return false;
if ($image_type == 1) {
$image = imagecreatefromjpeg($src_name);
} else {
return false;
}
break;
case '.png':
if(!function_exists("imagecreatefrompng")) return false;
if ($image_type == 3) {
$image = imagecreatefromjpeg($src_name);
} else {
return false;
}
break;
case '.jpg':
case '.jpeg':
if(!function_exists("imagecreatefromjpeg")) return false;
if ($image_type == 2) {
$image = imagecreatefromjpeg($src_name);
} else {
return false;
}
break;
}
return $image;
}
Bookmarks