VOOZH about

URL: https://froala.com/wysiwyg-editor/docs/sdks/ruby/references/image/

⇱ Ruby SDK Image Reference - Froala


June Special:  New customers get 40% off all Froala licenses
Days
Hours
Minutes
Seconds
x
Skip to content
Froala Documentation

Ruby SDK Image Reference

upload (params, fileRoute, options)

Returns: Object

Method used to upload image to the specified location on disk.

Parameters:


  • params

    The file that will be uploaded.

    Type: String

  • fileRoute

    The path relative to the Rails.root global variable were the image should be uploaded.

    Type: String

  • options

    This parameter is optional. It can be used to pass custom options for the image upload.

    Type: Array


options parameter:

  • fieldname

    The field name from the params[:file] global variable.

    Type: String
    Default:
    "file"
  • validation

    An array or a function used to validate the uploaded image. The array specifies the allowed image extensions through allowedExts and the allowed mime types through allowedMimeTypes. The function should be invoked with: filePath, and mimetype.

    Type: Array or Function
    Default:
    validation: {
     allowedExts: [".gif", ".jpeg", ".jpg", ".png", ".svg", ".blob"],
     allowedMimeTypes: [ "image/gif", "image/jpeg", "image/pjpeg", "image/x-png", "image/png", "image/svg+xml" ]
    }
    
  • resize

    An array with custom options to scale the image. Available options are the ones from MiniMagick::Image. Example:

    resize: {
     height: 200,
     width: 600
    }
    Type: Array
    Default:
    NULL

Response

If the upload is completed successfully, the method returns an object with the absolute path to the uploaded image. If an error occurs, the method will throw an exception

class UploadController < ActionController::Base

 ...

 def upload_image
 render :json => FroalaEditorSDK::Image.upload(params, "public/uploads/images/", options)
 end

 ...
 
end

delete ($src)

Returns: Boolean

Method used to delete an image from disk.

Parameters:


  • $src

    The path relative to the Rails.root global variable to the image that should be deleted.

    Type: String

list ($folderPath)

Returns: Array

Method used to list all images from disk.

Parameters:


  • $folderPath

    The path relative to the Rails.root global variable from where the images are being loaded.

    Type: String

Response

If the request is completed successfully, the method returns an array with images. If an error occurs, the method returns an error.

class UploadController < ActionController::Base

 ...

 def load_images
 render :json => FroalaEditorSDK::Image.load_images("public/uploads/images/")
 end

 ...
 
end
Related Plugin:

Do you think we can improve this article? Let us know.

Ready to dive in? Explore our plans

Froala AI Assistant

Hello! I'm your Froala AI assistant. How can I help you today?

Press Enter to send your message
Need human help? We're just a message away—reach out here.
How was your chat experience?

Your feedback helps us improve our AI assistant.

0/500