fix javascript error when previewImages is set to false