Skip to content

Commit 9076009

Browse files
committed
feat (img): add fallback for cloudinary - (2/2))
1 parent 9b52f99 commit 9076009

4 files changed

Lines changed: 14 additions & 5 deletions

File tree

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
<title>Pawsitive | Ashoka University</title>
77
<link href="https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600;700&family=Klee+One:wght@400;600&display=swap" rel="stylesheet">
88
<link rel="stylesheet" href="styles/main.css">
9-
<link rel="icon" type="image/jpeg" href="/https://res.cloudinary.com/duij1lw6u/image/upload/f_auto,q_auto/public/logo/Paws Logo.jpg">
9+
<link rel="icon" type="image/jpeg" href="https://res.cloudinary.com/duij1lw6u/image/upload/f_auto,q_auto/public/logo/Paws Logo.jpg">
1010
</head>
1111
<body>
1212

1313
<nav>
1414
<div class="logo" onclick="showPage('home')">
15-
<img src="/https://res.cloudinary.com/duij1lw6u/image/upload/f_auto,q_auto/public/logo/Paws Logo.jpg" alt="Pawsitive Logo" style="height:32px;vertical-align:middle;margin-right:8px;" onerror="_cldImgError(this)">
15+
<img src="https://res.cloudinary.com/duij1lw6u/image/upload/f_auto,q_auto/public/logo/Paws Logo.jpg" alt="Pawsitive Logo" style="height:32px;vertical-align:middle;margin-right:8px;" onerror="_cldImgError(this)">
1616
pawsitive
1717
</div>
1818
<div class="nav-links" id="nav-links">

js/app.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ function _cldImgError(img) {
99
if (img.dataset.fallback) { img.src = img.dataset.fallback; delete img.dataset.fallback; }
1010
}
1111

12+
/* ── Favicon fallback — <link rel="icon"> has no onerror, so probe via Image ── */
13+
(function () {
14+
const link = document.querySelector('link[rel="icon"]');
15+
if (!link) return;
16+
const probe = new Image();
17+
probe.onerror = function () { link.href = '/public/logo/Paws Logo.jpg'; };
18+
probe.src = link.href;
19+
}());
20+
1221
/* ── Shared scroll-lock utility (used by all modals) ── */
1322
function lockScroll() {
1423
document.body.style.overflow = 'hidden';

js/memoriam.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function initMemorialPhotos() {
8181
applyMemorialOrientation(img);
8282
img.classList.add('loaded');
8383
});
84-
img.addEventListener('error', () => { img.style.display = 'none'; });
84+
img.addEventListener('error', () => { _cldImgError(img); });
8585
}
8686
});
8787
}
@@ -212,7 +212,7 @@ function openMemorialModal(card) {
212212

213213
const photoSection = card.dataset.image
214214
? `<div class="dog-modal-photo memorial-modal-photo-wrap">
215-
<img src="${card.dataset.image}" alt="${card.dataset.name}" style="opacity:0;transition:opacity 0.3s" onload="this.style.opacity=1">
215+
<img src="${card.dataset.image}" alt="${card.dataset.name}" style="opacity:0;transition:opacity 0.3s" onload="this.style.opacity=1" onerror="_cldImgError(this)">
216216
</div>`
217217
: `<div class="dog-modal-emoji" style="background:${bg}">
218218
<span style="font-size:7rem">${card.dataset.emoji || '🐕'}</span>

pages/donate.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ <h3>where your money goes</h3>
1515
<div class="donate-card-head"><h3>📱 pay via UPI</h3><p>instant, zero-fee. scan the QR or copy the ID below.</p></div>
1616
<div class="donate-card-body">
1717
<div class="upi-qr-box">
18-
<img src="../https://res.cloudinary.com/duij1lw6u/image/upload/f_auto,q_auto/public/donate/upi-qr.jpeg" alt="UPI QR Code" class="upi-qr-img" />
18+
<img src="https://res.cloudinary.com/duij1lw6u/image/upload/f_auto,q_auto/public/donate/upi-qr.jpeg" alt="UPI QR Code" class="upi-qr-img" onerror="_cldImgError(this)" />
1919
</div>
2020
<div class="upi-id-row">
2121
<span class="upi-id-text" id="upiIdText">sendaveishaan1@okaxis</span>

0 commit comments

Comments
 (0)