- Compatibilité XF
- 2.3.x
- Description courte
- A lightweight WP Seasonal Logo Rotator template hack for automatic logo rotation without add-ons or maintenance. Ideal for seasonal branding with just image uploads in a folder. No filename editing needed. Installation steps included.
Créer un dossier de logos
Ajouter list.php
Créer list.php dans le même dossier.
What This Does
Scane un dossier de logos automatiquement
Choisit une image au hasard sur chaque chargement d'une page
Mettre à jour instantanément lorsqu'une image est ajoutée ou supprimée
Idéal pour la marque saisonnière ou événementielle
Check optional
Adapt largeur/hauteur pour correspondre à votre logo.
Ajouter JavaScriptPanel Administrateur → Apparence → Modèles →PAGE_CONTAINERCopieraprès{$ldJsonHtml|raw}
Notes
DisclaimerC'est une astuce de template, pas un addon.
Utilisez seulement si vous êtes confortable en exposant les noms de fichiers des logos via list.php.
Ajouter list.php
Créer list.php dans le même dossier.
What This Does
Scane un dossier de logos automatiquement
Choisit une image au hasard sur chaque chargement d'une page
Mettre à jour instantanément lorsqu'une image est ajoutée ou supprimée
Idéal pour la marque saisonnière ou événementielle
PHP:
<?php
header('Content-Type: application/json');
$allowed = ['webp', 'png', 'jpg', 'jpeg', 'gif', 'svg'];
$files = [];
foreach (scandir(__DIR__) as $file) {
if ($file === '.' || $file === '..' || $file === 'list.php') continue;
if (in_array(strtolower(pathinfo($file, PATHINFO_EXTENSION)), $allowed, true)) {
$files[] = $file;
}
}
echo json_encode($files);
Ajouter CSSPanel Administrateur → Apparence → Styles → Modèles →extra.less
CSS:
.p-header-logo {
position: relative;
width: 350px;
height: 300px;
}
.p-header-logo img {
visibility: hidden;
}
.p-header-logo::before {
content: "";
position: absolute;
inset: 0;
background-repeat: no-repeat;
background-position: center;
background-size: contain;
}
Ajouter JavaScriptPanel Administrateur → Apparence → Modèles →PAGE_CONTAINERCopieraprès{$ldJsonHtml|raw}
Code:
<script>
(async function () {
const folderPath = '/styles/season_logos/';
try {
const res = await fetch(folderPath + 'list.php');
if (!res.ok) return;
const logos = await res.json();
if (!logos.length) return;
const logo = logos[Math.floor(Math.random() * logos.length)];
const style = document.createElement('style');
style.textContent = `
.p-header-logo::before {
background-image: url("${folderPath}${logo}");
}
`;
document.head.appendChild(style);
} catch (e) {}
})();
</script>
DisclaimerC'est une astuce de template, pas un addon.
Utilisez seulement si vous êtes confortable en exposant les noms de fichiers des logos via list.php.