fix gallery widget image update algorithm