small refactoring in image galleries