Skip over folders in preview and fix going back bug

If using the arrow keys in preview, skip over any folders, otherwise
we'd jump into them.

There was also a bug when the going backwards beyond the first image.
The wraparound wasn't working properly.