Correctly generate image links (see #6249)