Fix gallery opening

- when there are no images
- when we have scrolled past the last image
Merge branch 'master' into catalog