/** * Helper function to get game image with fallback */ function getGameImage($imageUrl, $gameName = '') { // If image URL is from provider CDN, keep it if (strpos($imageUrl, 'tbs2api.dark-a.com') !== false) { return htmlspecialchars($imageUrl); } // If empty or placeholder, generate a colored placeholder if (empty($imageUrl) || strpos($imageUrl, 'via.placeholder.com') !== false) { // Generate a consistent color based on game name $color1 = substr(md5($gameName), 0, 6); $color2 = 'ffd700'; // Gold text $text = urlencode($gameName ?: 'Game'); return "https://via.placeholder.com/300x225/{$color1}/{$color2}?text={$text}"; } return htmlspecialchars($imageUrl); }