plupload icon indicating copy to clipboard operation
plupload copied to clipboard

addFileFilter - 'max_img_resolution' not working on GIF files

Open roldeguz opened this issue 7 years ago • 4 comments

Hi,

I am using plupload to upload images and used the addFileFilter function to restrict image dimensions. It is working well with JPGs and PNGs but not with GIFs.

I used the exact same code to implement the filtering found here.

But for some reason when uploading gif files, it always raises the onerror event.

Any ideas why?

Thank you!

roldeguz avatar Mar 20 '18 16:03 roldeguz

hi, I used max_img_resolution , but i got an error: o is not defined, did you got that?

plupload.addFileFilter('max_img_resolution', function(maxRes, file, cb) { var self = this, img = new o.Image();

        function finalize(result) {
          // cleanup
          img.destroy();
          img = null;
       
          // if rule has been violated in one way or another, trigger an error
          if (!result) {
            self.trigger('Error', {
              code : plupload.IMAGE_DIMENSIONS_ERROR,
              message : "Resolution exceeds the allowed limit of " + maxRes  + " pixels.",
              file : file
            });
             
          }
          cb(result);
        }
       
        img.onload = function() {
          // check if resolution cap is not exceeded
          finalize(img.width * img.height < maxRes);
        };
       
        img.onerror = function() {
          finalize(false);
        };
       
        img.load(file.getSource());
      });

CandiceCaiYu avatar Mar 24 '18 09:03 CandiceCaiYu

GIFs are not being considered images by Plupload, only JPEGs and PNGs.

jayarjo avatar Mar 26 '18 18:03 jayarjo

@CandiceCaiYu same error, do you fix it?

keyood avatar Oct 09 '18 05:10 keyood

I got the same error

Asifkrishaweb avatar Aug 15 '22 10:08 Asifkrishaweb