title: Extend Gutenberg core/image
body: <p>I've setup my JavaScript environment for Gutenberg and am now attempting to extend the core/image block to wrap HTML.</p>
  <pre><code>wp.hooks.addFilter(
    'blocks.getSaveElement',
    'slug/modify-get-save-content-extra-props',
    modifyGetSaveContentExtraProps
  );
  
  /**
   * Wrap image block in div.
   * 
   * @param {object} element 
   * @param {object} blockType 
   * @param {object} attributes 
   * 
   * @return The element.
   */
  function modifyGetSaveContentExtraProps(element, blockType, attributes) {
    // Check if that is not an image block.
    if (blockType.name !== 'core/image') {
      return element;
    }
    // Return the block with div wrapper.
    return (
      &lt;div className='nice-img'&gt;
        &lt;a href={attributes.url}&gt;
          {element}
        &lt;/a&gt;
      &lt;/div &gt;
    );
  }
  </code></pre>
  <p>Aside from this code throwing tons of block validation errors in the console (when editing the post), the code wraps the entire <code>{element}</code> which includes the caption. I need to somehow get the caption outside of the <code>{element}</code>.</p>
  <p>I'm shooting in the dark here. Can anyone please point me in the right direction?</p>