You assume that thumbnailSizes will not be empty.  It is probably a valid assumption. The only time we would filter out all of the thumbnail sizes is if the camera was broken and returning invalid lists.

Still, you should at least throw an error if this happens.   Or, in the caller, check for undefined and don't set the thumbnail size if we can't pick one that is valid.