PerfectlyNormal/tinymce-rails-imageupload — pull request #18 by jcuervo (2012-10-01 17:02:29+00:00)
Title: Some additional upload options

Usually we need some alignment options: Left, Center or Right.
Styles can be passed for the drop-down via (in the form):

<%= tinymce(uploadimage_hint: @article.id, styles: {med: "Medium (354px)", small: "Small (120x80)"}) %>

And the Alt for the image.

Need to add the corresponding fields to the image (or asset) model you wanted to use.

Here's a sample controller implementation:

class Admin::TinymceAssetsController < ApplicationController
before_filter :require_admin

def create
if params[:hint] #associate it to the article
@article = Article.find(params[:hint])
image = @article.images.new(:asset => params[:file])
image.alt = params[:alt]
image.default_size = params[:default_size]
image.alignment = params[:alignment]
if image.save
render json: {
image: {
url: image.try(:asset).try(:url, :small)
}
}, content_type: "text/html"
else
#image could not be saved
end
else
#no association
end
end
end