← back to 1940swallpaper
hero: rotate curated room-setting pool (hero-pool.json), guard >=1400px, no swatch blur
efdb3d63d16e9b143e97622c36dbc18b3e8f8ff9 · 2026-06-01 15:21:13 -0700 · Steve
Files touched
Diff
commit efdb3d63d16e9b143e97622c36dbc18b3e8f8ff9
Author: Steve <steve@designerwallcoverings.com>
Date: Mon Jun 1 15:21:13 2026 -0700
hero: rotate curated room-setting pool (hero-pool.json), guard >=1400px, no swatch blur
---
public/index.html | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/public/index.html b/public/index.html
index e10fc5e..25c76ad 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1092,26 +1092,26 @@ loadGridPage();
// takes the freshest 20, picks one per visit via localStorage counter.
// Falls back to static /hero-bg.jpg on any error.
(async function rotateHero() {
+ const bg = document.getElementById('heroBg') || document.getElementById('cinemaBg');
+ if (!bg) return;
+ let pool = [];
try {
- const r = await fetch('/api/products?limit=100');
- if (!r.ok) return;
- const d = await r.json();
- const items = (d.items || [])
- .filter(p => p && p.image_url && /^https:\/\/(?:cdn\.shopify\.com|designerwallcoverings\.com)\//.test(p.image_url))
- .sort((a,b) => String(b.created_at || '').localeCompare(String(a.created_at || '')))
- .slice(0, 20);
- if (!items.length) return;
- let visits = 0;
- try {
- visits = parseInt(localStorage.getItem('hero_visits') || '0', 10) || 0;
- localStorage.setItem('hero_visits', String(visits + 1));
- } catch(e) {}
- const pick = items[visits % items.length];
- // Strip _NxN size suffix to get the largest CDN variant
- const url = pick.image_url.replace(/(_\d+x\d*)(\.(jpg|jpeg|png|webp|gif))(\?|$)/i, '$2$4');
- const bg = document.getElementById('heroBg') || document.getElementById('cinemaBg');
- if (bg) bg.style.backgroundImage = "url('" + url + "')";
+ const r = await fetch('/hero-pool.json', { cache: 'no-store' });
+ if (r.ok) { const j = await r.json(); pool = Array.isArray(j) ? j : (j.images || []); }
} catch (e) {}
+ pool = (pool || []).filter(u => typeof u === 'string' && /^https?:\/\/|^\//.test(u));
+ if (!pool.length) return; // no curated pool -> keep sharp static hero
+ let visits = 0;
+ try { visits = parseInt(localStorage.getItem('hero_visits') || '0', 10) || 0; localStorage.setItem('hero_visits', String(visits + 1)); } catch (e) {}
+ const start = visits % pool.length;
+ (function tryAt(i) {
+ if (i >= pool.length) return; // none qualified -> static hero stays
+ const url = pool[(start + i) % pool.length];
+ const probe = new Image();
+ probe.onload = () => { if (probe.naturalWidth >= 1400) bg.style.backgroundImage = "url('" + url + "')"; else tryAt(i + 1); };
+ probe.onerror = () => tryAt(i + 1);
+ probe.src = url;
+ })(0);
})();
← 0f6640f header name → domain name '1940s Wallpaper' (remove odd bran
·
back to 1940swallpaper
·
FIX: dw-header was injected inside a doc-comment (never ran) 17cfccc →