[BUGFIX] Ensure variable imageSizes is an array before accessing its values