prepare($sql); $stmt->execute([$username]); $person = $stmt->fetch(); if ($person && !empty($person['HR_IMAGE'])) { // Output the BLOB image // Try to determine mime type, or default to jpeg $finfo = new finfo(FILEINFO_MIME_TYPE); $mime = $finfo->buffer($person['HR_IMAGE']); if ($mime === 'application/x-empty' || empty($mime)) { $mime = 'image/jpeg'; } header("Content-Type: $mime"); echo $person['HR_IMAGE']; exit; } } catch (PDOException $e) { // Silently fall back to UI Avatars on error } // If no image or error, redirect to fallback header("Location: $fallback_url"); exit;