Froala, Inc
It looks like you’re browsing an old version of Froala. Please go to the newer version of our docs for a more updated version.
- Back to Docs
- Install and Configure
- Image
- Server Upload
- Server Delete
- S3 Upload
- Resize
- Validation
- Image Manager
- Simple Server
- File
- Server Upload
- Server Delete
- S3 Upload
- Validation
- References
- Image
- File
- S3
Ruby Image Resize
How it works
- The image gets uploaded to your server.
- When the image is stored to the disk on server side, it is also resized.
Image Upload
In the Server Upload article we explain the steps to upload image on your server. After you insert an image in the rich text editor, you can resize it, but this only changes the width and height displayed in the browser, and not the physical size of the image. That should be done on server side.
Resize Image
The WYSIWYG editor's Ruby SDK comes with the possibility to resize the image when it is being stored on the disk. It is using the Ruby MiniMagick::Image method, therefore all the options available for it can be used.
class UploadController < ActionController::Base ... def upload_image options: { resize: { height: 200, width: 600 } } FroalaEditorSDK::Image.upload(params, "public/uploads/images/", options) end ... end
Complete Example
<script> $(function() { $('.selector').froalaEditor({ // Set the image upload URL. imageUploadURL: '/image_upload', imageUploadParams: { id: 'my_editor' } }) }); </script>
class UploadController < ActionController::Base ... def image_upload options: { resize: { height: 200, width: 600 } } render :json => FroalaEditorSDK::Image.upload(params, "public/uploads/images/", options) end ... end