简体   繁体   中英

How to limit image upload size TinyMCE RoR

I am using TinyMCE for Rails and cannot find how to limit image upload size. Does anyone know?

You can set up a custom validator in your model. For example:

validate :image_size_validation, :if => "!image.blank?"  

  def image_size_validation
    errors[:image] << "should be less than 1MB" if image.size > 1.megabytes
  end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM