Never mind the previous response, it turns out one can set image fields to EDITABLE. This saves them in XML. Using this technique the code is way simpler:
var dropdown = new Blockly.FieldDropdown(options,
function(newOp) {
this.sourceBlock_.getField('IMAGE').setValue(newOp);
});
this.appendDummyInput()
.appendField(dropdown, 'SOURCE')
.appendField(new Blockly.FieldImage('', 11, 11, '*'), 'IMAGE');
this.getField('IMAGE').EDITABLE = true;
this.setColour(20);
}
};
And add this to your toolbox:
<block type="