【发布时间】:2014-10-29 23:41:03
【问题描述】:
我需要在将图像上传到cloudinary 之前验证图像尺寸,因为我使用的是从表单直接上传。
$(".cloudinary-fileupload").fileupload(
# disableImageResize: false,
imageMinWidth : 460
imageMinHeight: 230
acceptFileTypes: /(\.|\/)(gif|jpeg|png|bmp|ico)$/i,
maxFileSize: 2097152,
processalways: (e,data) ->
if (data.files.error)
alert(data.files[0].error)
# dropZone: "#direct_upload"
start: (e) ->
$(".status").text "Starting upload..."
return
progress: (e, data) ->
$(".status").text "Uploading... " + Math.round((data.loaded * 100.0) / data.total) + "%"
return
fail: (e, data) ->
$(".status").text "Upload failed"
return
这是我的 jquery 文件,用于上传 ....
这是用于将图像上传到 cloudinary 的视图文件...
<%= cl_image_upload_tag(:image_id,
:html => {:id => "resource_image", :class => "hidden"},
:tags => "directly_uploaded",
:crop => :scale,
:maxFileSize => 2048,
:resource_type => "image",
:format => 'jpg',
:cloudinarydone => true,
:notification_url => new_image_url
) %>
请告诉我,如果图像的尺寸大于460 230,我希望上传图像,如何实现所需的功能,否则会生成提醒用户更改他选择的图片。
【问题讨论】:
标签: ruby-on-rails image dimensions cloudinary