PerfectlyNormal / tinymce-rails-imageupload

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

Question: is there any possibility to send model type/id to upload_file_url action ? #93

Closed raveman closed 6 years ago

raveman commented 6 years ago

Simple file uploading is nice, but it could be perfect if there is any ability to send model info with post url to get images uploaded based on models/other attrs, not only in one location.

Right now I see only possibility based on request.referrer, may be it is not a problem.

Thanks.

ZephiroRB commented 6 years ago

Hello, with gem tinymce-rails custom options can be passed to tinymce to override the global options specified in config/tinymce.yml:

view = tinymce uploadimage_form_url: "/add_image", uploadimage_hint: @post.id

routes.rb post 'add_image', to: "image#add"

image_controller.rb

class ImageController < ApplicationController
  def add
    id = params[:hint] # @post.id pass by view
  end
end