Fix last image showing up first in gallery