I've configured IMCE with "Maximum image resolution" = 800x600. When trying to upload a .swf file, I get an error that the image's dimensions are too large. I don't think that .swf files should be considered images.

Here's how I modified imce/inc/page.inc to ensure that only images of supported types (.jpg, .jpeg, .gif and .png) are passed to file_validate_image_resolution:

function imce_validate_all(&$file, $imce) {

  //fix FILE_EXISTS_ERROR bug. core bug #54223.
  if (!$file->destination && variable_get('imce_settings_replace', FILE_EXISTS_RENAME) == FILE_EXISTS_ERROR) {
    return array(t('File browser is set to reject the upload of existing files.'));
  }

  //validate image resolution only if filesize validation passes.
  //because user might have uploaded a very big image
  //and scaling it may exploit system memory.
  $errors = imce_validate_filesize($file, $imce['filesize']);
+  if (imce_image_info($file->filepath)) {//image must of a supported type
     if (empty($errors)) {//image resolution validation
      $errors = array_merge($errors, file_validate_image_resolution($file, $imce['dimensions']));
     }
+  }
  if ($imce['quota']) {//directory quota validation
  ...

Apologies but I don't quite know how to make a patch file.

Comments

apetryk’s picture

Category: support » bug
ufku’s picture

Title: Uploading .sfw files fails validation for image resolution » Valide image resolution for supported types only
Status: Active » Fixed

Committed. thanks.

ufku’s picture

Version: 6.x-1.4 » 6.x-2.x-dev

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.