Somehow, the function empty() does not determine value of $row["unix_exif_date_taken"] (EXIF_date_taken in MySQL) and therefore $row["unix_date_submitted"] always overrides in:
// The original code $date_taken = !empty($row["unix_exif_date_taken"]) ? $row["unix_exif_date_taken"] : $row["unix_date_submitted"];
In order to display the date when photo was actually taken, I had to: