rcode5 / image-wysiwyg-sample

Sample Sinatra/TwitterBootstrap app with Bootstrap-wysihtml5 and custom image dialog
32 stars 9 forks source link

Chooser shows uploaded image multiple times #2

Open eltoro opened 11 years ago

eltoro commented 11 years ago

Not sure if you're still maintaining this but if you upload an image, insert it and then try to upload a second image it gets added to the chooser 4 or 5 times. It happens on the demo also.

eltoro commented 11 years ago

Still haven't figure why it's happening but here is my workaround: I added a check if the uploaded image has been appended and toggle it to prevent another append: custom_image_wysihtml5.js ln 73:

isAppended = false; ... if(!isAppended){ chooser.append(optionTemplate({"file":res.file,"caption":res.caption})); isAppended = true; }

bunnymatic commented 11 years ago

I'm still maintaining this.

Can you fork and send a pull request? If not, i'll try to merge in and test that soon(ish).

cheers and thanks for the updates jon

bunnymatic commented 11 years ago

I did see it. I think the number of times it gets added to that list may be related to the size (time) of the image. When I did an upload (of 360k), I saw about 8 entries in the picker. I bet the jquery.uploader is firing events of some kind (like 10% complete, 20% complete) or something, and each of those is triggering the append.

I'll look into it. The uploader code came from another contributor so I don't know all the ins and outs, but i'd like to see it work.

As an alternative, you may want to check out http://mindmup.github.io/bootstrap-wysiwyg/. He's got a nice image upload image picker right out of the gate. My little bootstrap-wysiwyg upgrade may be getting to be obsolete.

cheers