Skip to content

V15: File upload should use better Image & SVG preview#18900

Merged
iOvergaard merged 7 commits intov15/devfrom
v15/bugfix/file-upload-svg-preview
Apr 1, 2025
Merged

V15: File upload should use better Image & SVG preview#18900
iOvergaard merged 7 commits intov15/devfrom
v15/bugfix/file-upload-svg-preview

Conversation

@iOvergaard
Copy link
Copy Markdown
Contributor

@iOvergaard iOvergaard commented Apr 1, 2025

Description

Similar to #18899, this changes the preview of SVGs on the Upload Field to use <uui-card-media />.

Fixes #18861

Changes

  • Adds same preview for SVG and Image using <uui-card-media />
  • Adds loading="lazy" on SVG and Image
  • Ensures that neither SVG nor Image can exceed its bounds (try testing with width: 10000px for example)
  • Adds a title attribute on Audio and Video

Screenshots

JPG/PNG

🔴 BEFORE
image

AFTER
image

SVG

🔴 BEFORE

image

AFTER
image

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the SVG preview in the Upload Field to use the component, improving the visual presentation of SVG uploads.

  • Introduces a computed property to extract the file name from the file path.
  • Replaces the simple element with a wrapper that includes an anchor for the image.
  • Updates styling to target the inner image instead of the host.
Comments suppressed due to low confidence (2)

src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-upload-field/preview/input-upload-field-svg.element.ts:9

  • [nitpick] Consider renaming '#label' to a more descriptive name like 'extractedFileName' for improved clarity.
get #label() {

src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-upload-field/preview/input-upload-field-svg.element.ts:16

  • Consider using property binding for the 'href' attribute (e.g., .href=${this.path}) instead of a string literal to ensure reactive updates align with the other bindings.
return html`<uui-card-media .name=${this.#label} href="${this.path}" target="_blank">`;

@iOvergaard iOvergaard changed the title V15: File upload should use better SVG preview V15: File upload should use better Image & SVG preview Apr 1, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the file upload preview functionality by wrapping image and SVG previews in a uui-card-media component. It extracts a label from the file path for improved accessibility and adjusts CSS styling for better layout control.

  • Replace plain tags with uui-card-media wrappers.
  • Introduce a private getter to extract file labels from paths.
  • Update CSS to improve layout consistency and background styling.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-upload-field/preview/input-upload-field-svg.element.ts Changed SVG preview rendering using uui-card-media and updated CSS styling
src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-upload-field/preview/input-upload-field-image.element.ts Changed image preview rendering using uui-card-media and updated CSS styling
src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-upload-field/input-upload-field.element.ts Updated CSS on the wrapper element for layout improvements
Comments suppressed due to low confidence (2)

src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-upload-field/input-upload-field.element.ts:259

  • Changing the wrapper's width to 100% could potentially alter the intended layout behavior compared to the previous 'fit-content' setting. Please confirm that this update aligns with the design requirements.
width: 100%;

src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-upload-field/preview/input-upload-field-image.element.ts:16

  • [nitpick] Consider adding tests to validate that the label extraction logic from the file path works correctly, ensuring that the correct value is passed to the uui-card-media component.
const label = this.#label;

@iOvergaard iOvergaard requested a review from leekelleher April 1, 2025 10:31
@iOvergaard iOvergaard enabled auto-merge (squash) April 1, 2025 10:35
Copy link
Copy Markdown
Member

@leekelleher leekelleher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! 🚀

I've added a little spacing between the preview and the remove button; as hovering over the remove button looked like it slightly overlapped the bottom of the preview.

@iOvergaard iOvergaard merged commit 19e873c into v15/dev Apr 1, 2025
23 checks passed
@iOvergaard iOvergaard deleted the v15/bugfix/file-upload-svg-preview branch April 1, 2025 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants