調整我想實現客戶端圖像使用Jquery-File-Upload調整:jQuery的文件上傳客戶端圖像的CoffeeScript的
https://github.com/blueimp/jQuery-File-Upload/wiki/Client-side-Image-Resizing
我想實現它的CoffeeScript,不過,使用一些文件上傳代碼,我從這個railscast發現:
http://railscasts.com/episodes/383-uploading-to-amazon-s3
我不知道如何使用的CoffeeScript納入disableImageResize例子。這就是我,這不工作(我可以運行的應用程序,但它似乎並沒有做任何調整大小):
jQuery ->
$('#new_image').fileupload
dataType: "script"
disableImageResize: /Android(?!.*Chrome)|Opera/
.test(window.navigator && navigator.userAgent),
imageMaxWidth: 667,
imageMaxHeight: 667
add: (e, data) ->
types = /(\.|\/)(gif|jpe?g|png)$/i
file = data.files[0]
if types.test(file.type) || types.test(file.name)
$('#images').append('<div class="placeholder"></div>');
$('.placeholder').hide();
data.context = $(tmpl("template-upload", file))
$('#imageUploadProgress').append(data.context)
data.submit()
else
alert("#{file.name} is not a gif, jpeg, or png image file")
progress: (e, data) ->
if data.context
progress = parseInt(data.loaded/data.total * 100, 10)
data.context.find('.bar').css('width', progress + '%')
if progress == 100
$('.placeholder').show();
# scroll to the bottom of the thumbGallery to show recently uploaded image
document.getElementById("images").scrollTop = document.getElementById("images").scrollHeight
誰能告訴我我在做什麼錯誤?我發現關於同一主題的其他StackOverflow的問題,但都沒有答案:
How to resize images client side using jquery file upload
Resizing image at client-side using JQuery file upload to amazon S3
這樣做的竅門 - 然而保持add回調會很好 –