Sha256: eed19881badbf1a0c79fe449b48446b318e3fd51383ce94d5a808e9bd5c82cf6

Contents?: true

Size: 782 Bytes

Versions: 12

Compression:

Stored size: 782 Bytes

Contents

module Headmin
  module Ckeditor
    def handle_upload
      blob = ActiveStorage::Blob.create_after_upload!(
        io: upload_params[:upload],
        filename: upload_params[:upload].original_filename,
        content_type: upload_params[:upload].content_type
      )
      render json: {
        urls: {
          "default": url_for(blob.variant(resize_to_limit: [1600, 1600], quality: 75)),
          "800": url_for(blob.variant(resize_to_limit: [800, 800], quality: 75)),
          "1024": url_for(blob.variant(resize_to_limit: [1024, 1024], quality: 75)),
          "1600": url_for(blob.variant(resize_to_limit: [1600, 1600], quality: 75))
        }
      }
    end

    private

    def upload_params
      params.permit(
        :upload, :locale
      )
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
headmin-0.2.9 app/controllers/concerns/headmin/ckeditor.rb
headmin-0.2.8 app/controllers/concerns/headmin/ckeditor.rb
headmin-0.2.7 app/controllers/concerns/headmin/ckeditor.rb
headmin-0.2.6 app/controllers/concerns/headmin/ckeditor.rb
headmin-0.2.5 app/controllers/concerns/headmin/ckeditor.rb
headmin-0.2.4 app/controllers/concerns/headmin/ckeditor.rb
headmin-0.2.3 app/controllers/concerns/headmin/ckeditor.rb
headmin-0.2.2 app/controllers/concerns/headmin/ckeditor.rb
headmin-0.2.1 app/controllers/concerns/headmin/ckeditor.rb
headmin-0.2.0 app/controllers/concerns/headmin/ckeditor.rb
headmin-0.1.2 app/controllers/concerns/headmin/ckeditor.rb
headmin-0.1.1 app/controllers/concerns/headmin/ckeditor.rb