PDO::ERRMODE_EXCEPTION, PDO::ATTR_TIMEOUT => 3] ); $raw = $pdo->query('SELECT site_images FROM app_settings WHERE id = 1')->fetchColumn(); return SiteImages::decode($raw); } catch (\Throwable $e) { return []; } } /** Absolute URL auf diesem Server (Vorschau-Dienste brauchen eine volle Adresse). */ function hifi_absolute_url(string $path): string { $https = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || strtolower($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '') === 'https'; $host = (string) ($_SERVER['HTTP_HOST'] ?? ''); if (!preg_match('/^[A-Za-z0-9.\-]+(:\d+)?$/', $host)) { $config = require __DIR__ . '/../config/config.php'; return rtrim($config['app']['site_url'], '/') . $path; } return ($https ? 'https://' : 'http://') . $host . $path; } $images = hifi_site_images(); if (!empty($images['og_image'])) { $url = htmlspecialchars(hifi_absolute_url($images['og_image']), ENT_QUOTES); // Alle Verweise auf das eingebaute Vorschaubild (og:image, twitter:image, JSON-LD). $html = preg_replace('#https?://[^"\s]*/og-image\.jpg#', $url, $html); $size = @getimagesize(__DIR__ . '/../uploads/' . basename($images['og_image'])); if ($size) { $html = preg_replace('#(#', '', $html); } } if (!empty($images['favicon'])) { $type = str_ends_with($images['favicon'], '.png') ? 'image/png' : (str_ends_with($images['favicon'], '.webp') ? 'image/webp' : 'image/jpeg'); $html = preg_replace( '##', '', $html ); } echo $html;