A drop-in avatar component with two variants: initials (default, privacy-safe) and photo (opt-in, gracefully falls back to initials on error). Three sizes, zero backend, no biometric data by default.
The avatar renders as colored initials by default. If the user opts in to a real photo, the component renders that image; if the image URL ever 404s, the component silently falls back to the initials version. The member never sees a broken-image icon.
This pattern resolves the tension from idea-10 (profile display: head-shot + first name as default) and idea-11 (avatar fallback). Members choose either a photo or initials — never both required, never a default that captures biometric data without consent.
Three sizes of the same member, initials variant only:
When a member chooses to share a photo, the component renders it. If the URL fails, it falls back to initials — quietly, with no flash of broken-image.
data-photo attribute is whatever the member uploads to the FlexiFunnels Media Library — never an external third-party URL that tracks the viewer.
Paste the markup below anywhere on a page. Set the variant, name, and (optionally) size and photo URL.
<span class="orb-avatar" data-variant="initials" <!-- "initials" or "photo" --> data-name="Alex Rivera" <!-- used to derive initials --> data-size="md" <!-- "sm" (32px), "md" (44px), "lg" (72px) --> ></span> <!-- With photo (photo variant): --> <span class="orb-avatar" data-variant="photo" data-name="Jordan Lee" data-size="md" data-photo="https://your-cdn.example/photo.jpg" ></span>
Paste this once per page, anywhere in the body (typically just before </body>). The script auto-derives initials from data-name, inserts an <img> for the photo variant, and wires the error-fallback.
<script> (function () { function initials(name) { if (!name) return '?'; var parts = name.trim().split(/\s+/); if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase(); return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase(); } function deriveColor(name) { // Stable per-name background color from a small accent ramp. var palette = ['#b04a2f', '#2e7d52', '#b58900', '#5b8cff', '#7c5bff', '#2a8a8a']; var sum = 0; for (var i = 0; i < name.length; i++) sum = (sum + name.charCodeAt(i)) | 0; return palette[Math.abs(sum) % palette.length]; } function render(el) { var variant = el.dataset.variant || 'initials'; var name = el.dataset.name || ''; var size = el.dataset.size || 'md'; el.setAttribute('data-size', size); var text = initials(name); el.setAttribute('aria-label', name); var span = document.createElement('span'); span.className = 'orb-avatar__initials'; span.textContent = text; el.appendChild(span); el.style.background = deriveColor(name); if (variant === 'photo' && el.dataset.photo) { var img = document.createElement('img'); img.src = el.dataset.photo; img.alt = name; img.onerror = function () { el.setAttribute('data-state', 'error'); }; img.onload = function () { el.setAttribute('data-state', 'ok'); }; el.appendChild(img); } } function init(root) { var nodes = (root || document).querySelectorAll('.orb-avatar'); nodes.forEach(render); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } window.ORBAvatar = { init: init, render: render }; })(); </script>