question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plugins: Size validation triggering before image resize

See original GitHub issue

Summary

I’m using both the Image Resize and File Validate Size plugins. I want to resize images before validating size so I loaded the Image Resize plugin before the File Validate Size plugin. Unfortunately the size validation takes place first which prevents the image resizing.

How to reproduce

FilePond.registerPlugin(
  FilePondPluginImageResize,
  FilePondPluginFileValidateSize
);

FilePond.setOptions({
  imageResizeTargetHeight: 2160,
  imageResizeTargetWidth: 3840,
  imageResizeUpscale: false,
  maxFileSize: '5MB'
});

FilePond.create(document.getElementById('filepond'));

Demo here

Expected behaviour

The image should be resized before the size validation takes places. In this case, the resizing would reduce the size below the threshold and the image would be allowed.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
AustPcommented, Jul 11, 2019

Awesome thanks rikschennink! It looks perfect.

1reaction
rikschenninkcommented, Jul 11, 2019

Just published a new version of the file size validation plugin. It now exposes the fileValidateSizeFilter hook. You can use it to filter the files that should be validated.

See code example in release: https://github.com/pqina/filepond-plugin-file-validate-size/releases/tag/2.2.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Client-side image resizing with file upload on WP Job Manager
I'm using the WP Job Manager with the Field Editor plugins to show my clients a file upload field on a form where...
Read more >
Smush Image Optimization Plugin Usage Documentation
This guide explains how to use Smush Pro's Image Optimizing features to compress, resize, and share all your images without sacrificing ...
Read more >
How to bind resize event in my custom plugin - Stack Overflow
Method 1: You can bind the function to the resize event. It'll run your function again every time there is a resize.
Read more >
jQuery Plugin To Trigger Resize Event On Multiple Elements
ResizeTriggering is a jQuery plugin to handle 'resize' event which allows to be sent to any containers when the size of the elements...
Read more >
jQuery resize event - Ben Alman
Why is a plugin needed for the resize event? ... which periodically checks for element size changes and triggers the event when appropriate....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found