Fix #986 for galleries

Use the correct path for images, which produces clean links.