- XF 兼容性
- 2.3.x
- 摘要
- 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.
WP Seasonal Logo Rotator (自动扫描 hack)
一个轻量级模板 hack,通过将图像放入文件夹来自动旋转论坛徽标,以适应季节、活动或微妙的品牌更新。
无需插件。
无需文件名编辑。
无需维护。
此 hack 会
自动扫描徽标文件夹
每次页面加载时随机选择一张图片
当添加或删除图片时立即更新
适用于季节性或基于事件的品牌形象
安装步骤:
1. 创建一个徽标文件夹
Optional检查:
调整宽度/高度以匹配您的LOGO。
添加JavaScript管理面板 → 外观 → 模板 →PAGE_CONTAINER请粘贴之后{$ldJsonHtml|raw}
Notes
免责声明这是一个简单的模板hack,不是附加组件。
仅在您舒适地将logo文件名暴露到list.php时使用。
一个轻量级模板 hack,通过将图像放入文件夹来自动旋转论坛徽标,以适应季节、活动或微妙的品牌更新。
无需插件。
无需文件名编辑。
无需维护。
此 hack 会
自动扫描徽标文件夹
每次页面加载时随机选择一张图片
当添加或删除图片时立即更新
适用于季节性或基于事件的品牌形象
安装步骤:
1. 创建一个徽标文件夹
2. 添加list.php创建list.php 在同一文件夹中。
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);
添加CSS管理面板 → 外观 → 样式 → 模板 →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;
}
添加JavaScript管理面板 → 外观 → 模板 →PAGE_CONTAINER请粘贴之后{$ldJsonHtml|raw}
代码:
<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>
- []每次加载页面时logo发生变化[]清除浏览器缓存后进行设置[]手机尺寸可能需要在extra.less中调整[]列表.php只暴露图片文件名
免责声明这是一个简单的模板hack,不是附加组件。
仅在您舒适地将logo文件名暴露到list.php时使用。