   return _id
 
 insert_image_save_func = (template, coll_name, my_id, field_name) ->
+  payload = template.payload_var.get()
+  if !payload?
+    return
+
+  console.log "uploading payload",payload
+
   fb = template.$("#insert_image")[0]
   upload_files = fb.files
   # FIXME: assert size(upload_files)<=1

  canvas.getContext('2d').drawImage original, 0, 0, canvas.width, canvas.height
  canvas

handle_file_step_two = ( chosen_file, template, opts ) ->
  payload = {original_file: chosen_file}
  if opts.full_image

    if opts.preserve_full_image
      payload.cached_image = opts.full_image

    max_width = 150 # from .no-thumb-item width
    max_height = 200 # from .no-thumb-item height

      scale = max_height/opts.full_image.height
      actual_width = opts.full_image.width*scale

    thumb_canvas = getThumbnail(opts.full_image, scale)

    console.log "thumb_canvas",thumb_canvas
    console.log "thumb_canvas.toBlob",thumb_canvas.toBlob
    payload.thumb_blob = get_blob( thumb_canvas, "image/jpeg", 0.8)

    div = template.find("#preview")
    $(div).empty()
    div.appendChild(thumb_canvas)
  template.payload_var.set( payload )
  template.upload_ready.set( true )

handle_files = (fileList, template) ->
