I don't think `$fileReference` can be an empty array. No `ezimage` row should be created when there is no image, and `getFileReferenceData()` queries this table, and returns null if no row is found by the query.

In which circumstances is the variable empty or an array with an empty path ?