-1
我需要驗證圖像尺寸,然後將其上傳到cloudinary
,因爲我使用的是直接從表單上傳。如何在上傳之前檢索圖像尺寸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
,我想要上傳圖像,否則會爲用戶生成警報,以更改他選擇的圖片。
fileuploadprocessalways :(e,data) - > width = data.img.width height = data.img.height console.log height //這是我的咖啡腳本文件,我正在使用您的代碼,但在控制檯上它仍然不打印任何高度,而且當放置進行中的功能說s不能得到未定義的屬性。 – 2014-09-12 04:32:53
您應該確保包含所有相關庫。請參閱:https://github.com/cloudinary/cloudinary_js#client-side-image-resizing-before-upload – 2014-09-14 08:44:07