Ruby on Rails
Monday, August 25, 2014
Here's another alternative for you---- check this out:
It is a fully-fledged CMS engine that actually has a file uploader built in (I think you can upload a file and then DRAG the file reference from the "Upload files" panel on the right into the content you are editing). This is a bit of a departure from what you originally started with, but consider that you would be leveraging a lot of open source code that is already working.
In general I would classify what you are trying to build as a pretty expensive thing to build. Something like comfortable-mexican-sofa would allow you to leverage a very similar CMS interface and build on top of work that is already in place.
-Jason
On Aug 25, 2014, at 3:33 PM, Jason Fleetwood-Boldt <tech@datatravels.com> wrote:
mmmm.... I see your problem. You want an "built-in" image uploader?That's actually pretty hard, but with a bit of work you will be able to pull that off.You have two basic strategies:1) Make the user upload the image file somewhere else (like amazon S3 bucket) using their own client (like an FTP client), then copy & paste the URL into your WYSIWYG editor (wrapped inside an image tag) ---- most editors let you do that easily.2) provide an interface for the user to upload the image from their computer to your website (I see now why you were going down the paperclip route). Then make some kind of interface that allows them to drop a string-style reference to the image into the WYSIWYG editor. In the app I'm currently working on, we have a special macro inside the editor so you use something like this:[IMAGE:123]When output, this macro actually replaces the block of text with the image with id 123. (While editing, the editor doesn't actually see the image, they only see the macro)If you're on Heroku, or designing for Scale, you have some special considerations when creating a web app that accepts large file uploads. Check out this article here which explains how it is done: https://devcenter.heroku.com/articles/paperclip-s3In particular, see the note on this page that says:Large files uploads in single-threaded, non-evented environments (such as Rails) block your application’s web dynos and can cause request timeouts and H11, H12 errors. For files larger than 4mb the direct upload method should be used instead.In particular, if your images files are large (they say larger than 4 MB, but I would even say larger than 500K), you need to do direct upload to S3. This is documented here https://devcenter.heroku.com/articles/direct-to-s3-image-uploads-in-railsAs you can see, this is actually a complicated can of worms (which is why you should strongly consider if option #1 above is better for you since it is much easier and quicker to implement)You could probably write an uploader using method #2 described above that works with TinyMCE and inserts some kind of high-level macro or the actual image tag using javascript. But you definitely would have to get your hands dirty with javascript.If you want to go with Method #2, I strongly recommend that you DO NOT do pass-through uploading on Heroku. Although it will work for very small files, at scale you will create long running-request bottlenecks that will affect other users of your app -- people who aren't even using the upload tool will see slow performance. The s3_direct_upload gem (below) is one solution to this problem (it is an implementation of what the Heroku article discusses when it says "Direct upload")see:
On Aug 25, 2014, at 2:30 PM, Frank R. <lists@ruby-forum.com> wrote:Does tinymce-rails have an image upload built-in?
If now, what other gem is needed to do this?--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8B526A09-F2D2-4397-B4D8-99F199857896%40datatravels.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment