[BUGFIX] PHP Warning: Invalid argument supplied for foreach()

When a item has no media objects getMediaSelection() gives a
PHP Warning.

This changes adds a check if there are media elements present.

Resolves: #54904
Change-Id: I36ea10ddb8338582d9cd9926e0a693d514b683df
Reviewed-on: https://review.typo3.org/26751
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer