Magic image upload logic a bit more generic. Bring over the image path generation logic.