Skip to content

IoT Hub: fall back to initials when a creator avatar fails to load - #778

Closed
pinkevmladchy wants to merge 1 commit into
mainfrom
iot-hub/avatar-fallback
Closed

pinkevmladchy wants to merge 1 commit into
mainfrom
iot-hub/avatar-fallback

Conversation

@pinkevmladchy

Copy link
Copy Markdown
Contributor

The IoT Hub now keeps a deleted creator's items published and only wipes their personal data: avatarUrl becomes null and the avatar resource (/api/resources/<uuid>) is deleted. Listing (/iot-hub/<category>/<slug>/) and creator (/iot-hub/creator/<id>/) pages are built ahead of time, so until the next site build they keep pointing at the deleted avatar and show a broken image.

  • src/scripts/avatar-fallback.ts (new): initAvatarFallback() finds img[data-avatar-img]. If the image fails to load, it removes the image and reveals the [data-avatar-initials] sibling. It also covers an image that already failed before the module script ran (complete && naturalWidth === 0).
  • src/components/IotHub/CreatorHero.astro (140px photo) and src/components/IotHub/DetailMeta.astro (32px creator badge): the initials block is now rendered next to the avatar, hidden while there is one, and each component loads the script. After a failed load the markup and styles match the avatarUrl = null case; the only addition is the data-avatar-initials attribute.

No other "Deleted creator" handling: the public API has no flag for a deleted creator.

pnpm check and eslint pass. Prettier warnings on the two .astro files predate this change. Not built locally.

Listing and creator pages are built ahead of time, so after a creator
deletes their account the pages keep pointing at the removed
/api/resources/<uuid> avatar until the next build and show a broken
image. Render the initials block alongside the avatar (hidden) and
reveal it if the image errors, matching the markup used when there is
no avatar at all.
@pinkevmladchy
pinkevmladchy deleted the iot-hub/avatar-fallback branch October 20, 2026 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant