You return previewSizeAdjustments[0].previewSize here and when you call this function you check for the scale attribute that doesn't exist