Allow jpe, jfif and jif image extensions

1.9.x
Yannick Warnier 11 years ago
parent 967c870018
commit c78e35c36f
  1. 4
      main/auth/profile.php
  2. 3
      main/inc/lib/main_api.lib.php
  3. 2
      main/inc/lib/usermanager.lib.php

@ -216,8 +216,8 @@ if (is_profile_editable() && api_get_setting('profile', 'picture') == 'true') {
if (!empty($user_data['picture_uri'])) { if (!empty($user_data['picture_uri'])) {
$form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage')); $form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage'));
} }
$allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif'); $allowed_picture_types = api_get_supported_image_extensions();
$form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types); $form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(', ', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
} }
// LANGUAGE // LANGUAGE

@ -7478,7 +7478,8 @@ function api_get_configuration_value($variable)
*/ */
function api_get_supported_image_extensions() function api_get_supported_image_extensions()
{ {
$supportedImageExtensions = array('jpg', 'jpeg', 'png', 'gif', 'svg'); // jpg can also be called jpeg, jpe, jfif and jif. See https://en.wikipedia.org/wiki/JPEG#JPEG_filename_extensions
$supportedImageExtensions = array('jpg', 'jpeg', 'png', 'gif', 'svg', 'jpe', 'jfif', 'jif');
if (version_compare(PHP_VERSION, '5.5.0', '>=')) { if (version_compare(PHP_VERSION, '5.5.0', '>=')) {
array_push($supportedImageExtensions, 'webp'); array_push($supportedImageExtensions, 'webp');
} }

@ -1265,7 +1265,7 @@ class UserManager
} }
// Validation 2. // Validation 2.
$allowed_types = array('jpg', 'jpeg', 'png', 'gif'); $allowed_types = api_get_supported_image_extensions();
$file = str_replace('\\', '/', $file); $file = str_replace('\\', '/', $file);
$filename = (($pos = strrpos($file, '/')) !== false) ? substr($file, $pos + 1) : $file; $filename = (($pos = strrpos($file, '/')) !== false) ? substr($file, $pos + 1) : $file;
$extension = strtolower(substr(strrchr($filename, '.'), 1)); $extension = strtolower(substr(strrchr($filename, '.'), 1));

Loading…
Cancel
Save