I can't say why your gallery got wiped in Safe Mode, but that shouldn't happen. All Safe Mode does is temporarily disable any 3rd party apps, which then get reenabled when you boot back into normal mode. A gallery app also doesn't store the actual photos -- the photo files are stored in a separate directory (typically /DCIM/Camera, if they were taken by the camera app), and the system builds a gallery database of all images saved to the phone's storage. If this database is cleared, then opening the gallery app again should prompt the database to be rebuilt.
In addition, if those photos are important to you, this is a good opportunity to make sure they're backed up somewhere, either to a physical drive (i.e., on your computer), or in the cloud (e.g., Google Photos).