Skip to content

Instantly share code, notes, and snippets.

@b-murphy
Created April 25, 2014 10:41
Show Gist options
  • Save b-murphy/11285152 to your computer and use it in GitHub Desktop.
Save b-murphy/11285152 to your computer and use it in GitHub Desktop.
issue with cropping image : filepicker
ADF.SpaceImageUploadView = Ember.View.extend(
didInsertElement: ->
_this = this
this.$("input.image_uploader").on('click', ->
storePath = "/space/#{_this.get('controller.model.id')}/images/"
filepicker.pickAndStore({multiple: true, folders: true, mimetype: 'image/*', isWriteable: false}, {path: storePath, container: 'adoorfor'}, (data) ->
_.each(data, (rawData) ->
_this.resizeImage(rawData)
)
)
)
resizeImage: (rawData) ->
_this = this
storePath = "/space/#{this.get('controller.model.id')}/images/profile/"
console.log(rawData)
filepicker.convert({
mimetype: rawData.mimetype,
url: rawData.url,
filename: rawData.filename,
isWriteable: false,
size: rawData.size,
},
{ width: 400 },
{ path: storePath, container: 'adoorfor' }, # settings
(imageData) ->
_this._createImageRecord(imageData.url, rawData.url)
)
_createImageRecord: (url, originalUrl) ->
_this = this
image = App.Image.createRecord(url: url, original_url: originalUrl)
image.save().then( ->
_this.get('controller.model.images').pushObject(
image
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment