//
// Options (array en 3e param) :
// widths : largeurs candidates pour srcset (def: [200,400,600,900,1400])
// sizes : attribut sizes (def: 'auto')
// loading : 'lazy' (def) ou 'eager' (pour image LCP)
// q : qualité WebP 30..95 (def: 80)
// class, style, width, height : attributs classiques
// attrs : attributs HTML supplémentaires ['fetchpriority'=>'high', ...]
//
// Notes :
// - Sur loading="eager" (LCP), prefer un sizes explicite plutôt que 'auto'.
// - L'image par défaut (src=) est prise dans la médiane des widths.
if (!function_exists('img')) {
function img($src, $alt = '', array $opts = []) {
global $version;
$widths = $opts['widths'] ?? [200, 400, 600, 900, 1400];
$sizes = $opts['sizes'] ?? 'auto';
$loading = $opts['loading'] ?? 'lazy';
$quality = (int)($opts['q'] ?? 80);
$w = $opts['width'] ?? null;
$h = $opts['height'] ?? null;
$class = $opts['class'] ?? '';
$style = $opts['style'] ?? '';
$extra = $opts['attrs'] ?? [];
$vParam = isset($opts['v']) ? $opts['v'] : ($version ?? null);
// Auto-détection des dimensions source si absentes
if ((!$w || !$h) && !empty($_SERVER['DOCUMENT_ROOT'])) {
$srcPath = rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/' . ltrim($src, '/');
if (is_file($srcPath) && ($info = @getimagesize($srcPath))) {
if (!$w) { $w = $info[0]; }
if (!$h) { $h = $info[1]; }
}
}
$encSrc = rawurlencode(ltrim($src, '/'));
$vStr = $vParam !== null ? '&v=' . rawurlencode((string)$vParam) : '';
$srcset = [];
foreach ($widths as $wCand) {
$wCand = (int)$wCand;
if ($wCand < 1) continue;
$srcset[] = "/img.php?src={$encSrc}&w={$wCand}&q={$quality}{$vStr} {$wCand}w";
}
// src par défaut : valeur médiane
$defaultW = (int)$widths[(int)floor(count($widths) / 2)];
$defaultSrc = "/img.php?src={$encSrc}&w={$defaultW}&q={$quality}{$vStr}";
$altEsc = htmlspecialchars($alt, ENT_QUOTES, 'UTF-8');
$attrs = '';
if ($class !== '') $attrs .= ' class="' . htmlspecialchars($class, ENT_QUOTES, 'UTF-8') . '"';
if ($style !== '') $attrs .= ' style="' . htmlspecialchars($style, ENT_QUOTES, 'UTF-8') . '"';
if ($w) $attrs .= ' width="' . (int)$w . '"';
if ($h) $attrs .= ' height="' . (int)$h . '"';
foreach ($extra as $k => $v) {
$attrs .= ' ' . htmlspecialchars($k, ENT_QUOTES, 'UTF-8')
. '="' . htmlspecialchars((string)$v, ENT_QUOTES, 'UTF-8') . '"';
}
return ' ';
}
}
14 Free Winder Sound Effects — Download WAV & MP3
Your browser does not support JavaScript! The site will not work properly. Please enable it.
All files whose download pages mention "Free and Royalty Free" (at the top of the page or in the download box) are made available free of charge and
freely for all your projects, whether commercial or not, and worldwide.