An update to format-gallery.php

The code does not display the images in the gallery. So I wrote the new version of the code above. Please feel free tot test. Thanks