PerfectlyNormal / tinymce-rails-imageupload

Image upload plugin for TinyMCE and Rails with the asset pipeline
MIT License
149 stars 153 forks source link

Set Content-Type to application/json in response #7

Closed aaronchi closed 6 years ago

aaronchi commented 12 years ago

I noticed that the plugin doesn't work if you actually return a json response. It seems to only work if you send a text/html response with json in it. I assume this is due to the way that the response is being parsed in the javascript.

Great start on a simple upload plugin though. Would be great to extend it and include a list view as well with a configurable endpoint for pulling in the image details.

Thanks!

PerfectlyNormal commented 12 years ago

Yeah, I know it has a few warts. Found some code that did the job, packaged it and played around 'til I got it working "good enough" for my needs. Planning on making it a bit nicer as time permits.

I see I forgot to mention the content_type bit. Wrote a short line in the readme, and I'll see if I can't get that fixed as well. Thanks for letting me know.

PerfectlyNormal commented 12 years ago

Gave this a little try today, and got it working in Safari, Chrome and the likes when using application/json or text/javascript or pretty much any encoding. Only problem was IE, who attempts to download it the second something other than text/html gets sent.

So from what I can see while researching, as long as we use a iframe for the uploading (which needs to be done to support IE and Opera), the content-type needs to be text/html or text/plain

Darkside73 commented 10 years ago

Can you publish your efforts as a branch? I'm don't care about IE and Opera

PerfectlyNormal commented 10 years ago

Hi.

I'm terribly sorry, but looks like I don't have that any more. I've moved machines since I played around with that, and that little experiment disappeared.

Don't really remember how I did it either. Sorry about that.

Looooong commented 6 years ago

can we append format to the link? Like /tinymce_assets.json

PerfectlyNormal commented 6 years ago

@Looooong might be possible to do and get a sensible response. Have you tried it?

The url the plugin uses can be customized. I don’t remember the exact parameter name, but it’s listed in the readme