Media: Add umb-media-thumbnail with configurable checkerboard background (closes #23177) - #23178
Conversation
Adds `umb-thumbnail` as the recommended alias of `umb-imaging-thumbnail` (the original tag stays registered for backwards compatibility), and makes the checkerboard background opt-out via the `--umb-thumbnail-background` CSS custom property plus an `img` part for full styling control. Also fixes an action-event listener leak in the thumbnail element, and adds a Storybook story, an MDX guide, and component tests. Closes #23177 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude finished @iOvergaard's task in 6m 9s —— View job PR ReviewTarget: Adds
Suggestions
Approved with Suggestions for improvementThe listener-leak fix is correct — the arrow-function class field keeps a stable reference so |
There was a problem hiding this comment.
Pull request overview
This PR improves Umbraco’s backoffice imaging UX by introducing a recommended umb-thumbnail alias for the existing umb-imaging-thumbnail, while making the checkerboard transparency background configurable via a CSS custom property and exposing the internal <img> for styling.
Changes:
- Added
umb-thumbnailas an alias ofumb-imaging-thumbnailand exported it from the imaging components index. - Made the checkerboard background configurable via
--umb-thumbnail-background(default unchanged) and exposed the rendered<img>aspart="img". - Fixed an action-event listener leak by ensuring the
UmbEntityUpdatedEventlistener is removed on disconnect; added Storybook docs/stories and component tests.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Umbraco.Web.UI.Client/src/packages/media/imaging/stories/working-with-media-images.mdx | Adds a guide describing when to use umb-thumbnail/umb-media-image, and how to disable the checkerboard / style the img part. |
| src/Umbraco.Web.UI.Client/src/packages/media/imaging/components/thumbnail.stories.ts | Adds Storybook stories for default checkerboard, transparent background override, and fallback icon behavior. |
| src/Umbraco.Web.UI.Client/src/packages/media/imaging/components/thumbnail.element.ts | Registers umb-thumbnail as the recommended alias for the imaging thumbnail element with JSDoc for cssprop/csspart. |
| src/Umbraco.Web.UI.Client/src/packages/media/imaging/components/thumbnail.element.test.ts | Adds tests covering aliasing, part="img", default checkerboard, and background override behavior for umb-thumbnail. |
| src/Umbraco.Web.UI.Client/src/packages/media/imaging/components/index.ts | Exports the new thumbnail.element.js from the imaging components barrel. |
| src/Umbraco.Web.UI.Client/src/packages/media/imaging/components/imaging-thumbnail.element.ts | Adds part="img", introduces --umb-thumbnail-background, and fixes action-event listener cleanup on disconnect. |
| src/Umbraco.Web.UI.Client/src/packages/media/imaging/components/imaging-thumbnail.element.test.ts | Adds tests covering part="img" and --umb-thumbnail-background behavior for umb-imaging-thumbnail. |
- Rephrase the imaging-thumbnail JSDoc to a neutral alias statement instead of a "prefer" wording that read like an undeclared deprecation. - Guard the thumbnail tests so a renamed private field fails loudly rather than producing vacuous assertions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Thanks for the review — both addressed in 3165423:
Note for context: migrating the four internal |
…thumbnail Invert the inheritance so the implementation lives on `UmbThumbnailElement` (`umb-thumbnail`) and `UmbImagingThumbnailElement` (`umb-imaging-thumbnail`) is the thin subclass. Removing the old tag is now just deleting one file. The deprecated subclass emits a one-time `UmbDeprecation` warning (a module-level guard avoids per-instance console spam) and carries a `@deprecated` JSDoc, scheduled for removal in Umbraco 19. Migrate the four internal consumers to `umb-thumbnail` so the deprecation warning targets external code only, not our own. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://orange-sea-0c7411a03-23178.westeurope.6.azurestaticapps.net |
…guard The img part, checkerboard default and --umb-thumbnail-background override are covered by thumbnail.element.test.ts and inherited from UmbThumbnailElement, so re-asserting them on the umb-imaging-thumbnail subclass only tested inheritance. Keep a single backwards-compat guard that the deprecated alias stays registered and on the inheritance chain. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://orange-sea-0c7411a03-23178.westeurope.6.azurestaticapps.net |
…lias keeps @deprecated, no runtime warning Per review (Niels): the forward-looking name is `umb-media-thumbnail` (`UmbMediaThumbnailElement`), leaving room for non-media thumbnails later. The implementation, CSS custom property (`--umb-media-thumbnail-background`), story, guide and internal consumers all use the new name. `umb-imaging-thumbnail` stays registered as a thin alias and keeps its `@deprecated` JSDoc (IDE signal) but no longer emits a runtime UmbDeprecation warning — both tags fly for now. Docs and comments lead with umb-media-thumbnail. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Updated per the review:
Tests green, no circular deps, lint clean (bar the expected self-deprecation notice on the alias's own tag-map entry). |
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://orange-sea-0c7411a03-23178.westeurope.6.azurestaticapps.net |
Prerequisites
If there's an existing issue for this PR then this fixes #23177
Description
From discussion #23177: the media thumbnail always renders transparent images over a checkerboard pattern. That's right when managing media (it signals transparency to an editor) but wrong when the thumbnail represents final content (block grid items, pickers feeding the front-end), where the image should sit on a transparent background. It's also the only turnkey component that does server-side cropping —
umb-media-imagerespects transparency but can't crop — so people were dropping down toUmbImagingRepositoryby hand ("a lot of work just showing an image"). This closes that gap and gives the component a clearer, forward-looking name.Changes
umb-media-thumbnailis the component (UmbMediaThumbnailElement). The name leaves room for non-media thumbnails in future (per review).--umb-media-thumbnail-backgroundCSS custom property (default unchanged). Set it tononefor a transparent background; it inherits, so it can be set on any ancestor.imgpart — the underlying<img>is exposed aspart="img"for full styling control (object-fit,border-radius, …).umb-imaging-thumbnailis kept as a thin alias ofumb-media-thumbnail— both tags are supported for now. It keeps a@deprecatedJSDoc marker (so IDEs steer you to the new name) but emits no runtime warning.umb-media-thumbnail(media collection card, media picker, input-media, input-rich-media).#observeActionEventadded anUmbEntityUpdatedEventlistener to the app-level action-event context and never removed it; now cleaned up on disconnect (following themedia-workspace.context.tspattern).Entity/Media/Components/Media Thumbnail), an MDX guide (Guides/Working with Media Images), and component tests covering the part, the--umb-media-thumbnail-backgroundopt-out, and the alias relationship.How to test
cd src/Umbraco.Web.UI.Client && npm test -- --files "src/packages/media/imaging/**/*.test.ts"— green;npm run check:circularreports no cycles.npm run storybook→ Entity/Media/Components/Media Thumbnail: Default shows the checkerboard behind a transparent image; Transparent Background (--umb-media-thumbnail-background: none) shows it on a solid colour with no checkerboard.<umb-imaging-thumbnail>still works as an alias.Fixes #23177
🤖 Generated with Claude Code