Merged gallery image fix from upstream/dev branch