Re: Plugin: Avatar Upload
I have found that there are many more mime-types out there. Heres a list of extension to mime-type associations that you might want to add. I have built up this list over the last few years of real world use of applications.
'png' => 'image/png'
'png' => 'image/x-png'
'png' => 'application/png'
'png' => 'application/x-png'
'jpg' => 'image/jpeg'
'jpg' => 'image/jpg'
'jpg' => 'image/jp_'
'jpg' => 'image/pjpeg'
'jpg' => 'image/pjpg'
'jpg' => 'image/pipeg'
'jpg' => 'application/jpg'
'jpg' => 'application/x-jpg'
'jpeg' => 'image/jpeg'
'jpeg' => 'image/jpg'
'jpeg' => 'image/jp_'
'jpeg' => 'image/pjpeg'
'jpeg' => 'image/pjpg'
'jpeg' => 'image/pipeg'
'jpeg' => 'application/jpg'
'jpeg' => 'application/x-jpg'
'gif' => 'image/gif'
'gif' => 'image/gi_'
.
Of course, you would have to adapt your code to handle multiple mime types for each extension like so (or similar)…
Line 31:
$allowed_types = array(
'gif' => array(
'gif' => 'image/gif',
'gif' => 'image/gi_'
),
'jpg' => array(
'image/jpeg',
'image/jpg',
'image/jp_',
'image/pjpeg',
'image/pjpg',
'image/pipeg',
'application/jpg',
'application/x-jpg'
),
'png' => array(
'image/png',
'image/x-png',
'application/png',
'application/x-png'
)
);
$allowed_types['jpeg'] = $allowed_types['jpg'];
.
Line 124:
if ($error == 0 && (!in_array($img_type, $allowed_types[$img_ext]) || !in_array($img_ext, $allowed_extns)) ) {
.
Then remove the next conditional block from line 130 to line 134 because that check is now covered in the previous conditional block.