Wrap all output blocks from same chunk with media
Redo img wrapping code

fixes #20 and #22