Skip to content
This repository was archived by the owner on Jun 5, 2022. It is now read-only.

Single image option not working #87

Open
simdani opened this issue Oct 21, 2018 · 6 comments
Open

Single image option not working #87

simdani opened this issue Oct 21, 2018 · 6 comments

Comments

@simdani
Copy link

simdani commented Oct 21, 2018

singleImage prop is still not working correctly when you set it to true, it still lets upload multiple images.

@bilal68
Copy link

bilal68 commented Nov 12, 2018

any update on this one

@dmitrijBerg
Copy link

This Issue is very closely related to Issue #59 , I left a comment there.

@taylorgannon
Copy link

So far my best quick fix is to add display: 'none' to the buttonStyles prop if there are 1 or more images. This way the button does not appear.

@oranefayer
Copy link

oranefayer commented Sep 3, 2019

Hi!
i've been facing the same problem right now and i've found a better/complementary trick...

if you use this css :

.uploadPictureContainer:not(:last-of-type) {
    display: none;
}

only the last selected image will show in the preview, allowing the user to change he's mind and choose an other image whitch visualy will replace previous one.
you just need to fix your internal code to only use the last file from the pictures array.

Hope it helps
:]

@edmarjsg
Copy link

edmarjsg commented Nov 9, 2019

Only issue with using display: none is that if a user deletes the last addition, the old one re-appears. The one that worked best for me was to disable the button when the first image is added:

document.getElementsByClassName("chooseFileButton")[0].disabled = true;

And to make sure your users know that only 1 file is permitted, you can mention that in the label of the ImageUploader component.

@beautyfree
Copy link

Actual

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants