refactore image and image_gallery controller