       when "br"
         unless nodeIsExtraBR(node)
           @appendStringWithAttributes("\n", getAttributes(node))
-      when "img"
-        attributes = getAttributes(node)
-        attributes.url = node.getAttribute("src")
-        attributes[key] = value for key in ["width", "height"] when value = node.getAttribute(key)
-        if figure = Trix.DOM.closest(node, "figure.attachment")
-          attributes[key] = value for key, value of getMetadata(figure)
-        @appendAttachmentForAttributes(attributes)
       when "figure"
-        if node.classList.contains("attachment") and node.classList.contains("file")
-          attributes = getAttributes(node)
-          attributes[key] = value for key, value of getMetadata(node)
-          @appendAttachmentForAttributes(attributes)
+        if node.classList.contains("attachment")
+          attributes = getMetadata(node)
+          textAttributes = getAttributes(node)
+          if image = node.querySelector("img")
+            textAttributes.width = image.width if image.width?
+            textAttributes.height = image.height if image.height?
+          @appendAttachmentForAttributes(attributes, textAttributes)
           # We have everything we need so avoid processing inner nodes
           node.innerHTML = ""
 

        @processElementNode(node)

  appendBlockForNode: (node) ->
    if @currentBlockElement?
      unless @currentBlockElement.contains(node)
        @appendBlockForAttributes({})
        delete @currentBlockElement

    if node.nodeType is Node.ELEMENT_NODE
      if window.getComputedStyle(node).display is "block"
        switch node.tagName.toLowerCase()
          when "blockquote"
            @appendBlockForAttributes(quote: true)
            @currentBlockElement = node
          when "pre"
            @appendBlockForAttributes(code: true)
            @currentBlockElement = node

    unless @blocks.length
      @appendBlockForAttributes({})

    text = Trix.Text.textForStringWithAttributes(string, attributes)
    @appendText(@text.appendText(text))

  appendAttachmentForAttributes: (attributes, textAttributes) ->
    attachment = if @attachments and attributes.id
      @attachments.get(attributes.id)
    else
      delete attributes.id
      new Trix.Attachment attributes

    text = Trix.Text.textForAttachmentWithAttributes(attachment, textAttributes)
    @appendText(@text.appendText(text))

  appendText: (@text) ->
    index = @blocks.length - 1
    block = @blocks[index]
    @blocks[index] = block.copyWithText(@text)

  getDocument: ->
    new Trix.Document @blocks
