0

We need to give an ability to user to upload an image related to Account in a Lightning Component. This can be easily done with standard lightning:fileUpload component without any need to send file data to controller by code. The component handles it itself.

Now, we want to have a check on image dimensions - the image should be 200x200 dimensions only. I do not see anything in the documentation which can help me do this. If there is an event which is fired before saving the files and we can handle it, then this can be easily done provided it also gives us file properties.

Can anyone help/suggest a solution to this?

0

Like you said this is not possible with lightning:fileUpload since you can't check an image before already uploading it.

You could check when finished uploading, but that is quite cumbersome and quite bad for performance.

Not sure, but maybe a trigger could do the trick where you do the validation on the beforeInsert event?

  • Even if I decide to do it in onUploadFinished, it doesn't give me all the properties of the file. It just gives fileName and documentId. Another thing I just found out is - we cannot check the dimensions directly. The file needs to be uploaded so that we can create an Image object in Javascript to load the image and then check it's dimensions. – ajinkyah Aug 30 '18 at 11:56
0

There is an AppExchange app to help you to do so. SharinPix not only get the file uploaded and notify you at update with the image EXIf information ( on wich you can find the image size ) but can also normalize the uploaded picture to a 200x200 pixels version on the fly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.