Skip to content

Image cropper: Modal import missing component#20651

Merged
leekelleher merged 11 commits intoumbraco:mainfrom
bjarnef:feature/image-cropper-modal-import-missing-component
Dec 2, 2025
Merged

Image cropper: Modal import missing component#20651
leekelleher merged 11 commits intoumbraco:mainfrom
bjarnef:feature/image-cropper-modal-import-missing-component

Conversation

@bjarnef
Copy link
Copy Markdown
Contributor

@bjarnef bjarnef commented Oct 25, 2025

Prerequisites

  • I have added steps to test this contribution in the description below

If there's an existing issue for this PR then this fixes #20596

Description

The SVG preview didn't work in image cropper modal because the component wasn't imported in modal, so it only rendered <umb-file-upload-preview></umb-file-upload-preview> in DOM.

This includes the missing component.

Furthermore a SVG without dimensions also need a width/minimum width, otherwise the width was calculated to zero.

SVG image with width/height

image

SVG image without width/height

image

We can possible make <umb-input-upload-field-svg> fill more of width/height - at least in image cropper modal even SVG contains dimensions as we know this is used specific for SVG files.. furthermore icons uploaded by content editor often may contain a small size like 16x16, 24x24 or 32x32 .. so it would be nicer with a larger preview.

with height: 100% on umb-input-upload-field-svg element.

image

Copilot AI review requested due to automatic review settings October 25, 2025 19:42
@github-actions
Copy link
Copy Markdown

github-actions bot commented Oct 25, 2025

Hi there @bjarnef, thank you for this contribution! 👍

While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:

  • It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
  • The automated tests all pass (see "Checks" tab on this PR)
  • The level of security for this contribution is the same or improved
  • The level of performance for this contribution is the same or improved
  • Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
  • If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
  • 💡 The contribution looks original and the contributor is presumably allowed to share it

Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution.

If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

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 fixes a missing component import that was causing the image cropper modal to fail. The fix adds an explicit import for the file upload preview component and addresses related TypeScript non-null assertion issues where the mimeType is guaranteed to be defined.

Key Changes:

  • Added missing import for file-upload-preview.element.js in the image cropper editor modal
  • Added non-null assertions for mimeType usage to satisfy TypeScript checks

Reviewed Changes

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

File Description
src/Umbraco.Web.UI.Client/src/packages/media/media/modals/image-cropper-editor/image-cropper-editor-modal.element.ts Adds missing import statement for file upload preview component
src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-upload-field/file-upload-preview.element.ts Adds non-null assertions for mimeType variable usage

@emmagarland emmagarland force-pushed the feature/image-cropper-modal-import-missing-component branch from 745b6a2 to eb0b2f4 Compare November 4, 2025 13:58
@emmagarland
Copy link
Copy Markdown
Collaborator

Hi @bjarnef

Thanks again for the PR to fix #20596, where a missing component import was causing the image cropper modal to fail.

One of the team will check and make sure all is good (I have a new computer setup so I don't have it handy to check right now).

PS I've taken the liberty to rebase to get the latest changes from `main1 into this branch, hope that is ok.

Best regards

Emma

@bjarnef
Copy link
Copy Markdown
Contributor Author

bjarnef commented Nov 17, 2025

@nielslyngsoe I think this is also at issue with latest changes for v17 :)

@leekelleher leekelleher self-requested a review December 2, 2025 16:06
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.

Thanks @bjarnef. I've tested this out and it works great. 🙏

@leekelleher
Copy link
Copy Markdown
Member

leekelleher commented Dec 2, 2025

Ah, I've just noticed that this created a circular dependency in the "media" package. I'll look into unpicking that and update accordingly.

Okay, fixed the circular dependency! 👍

@leekelleher leekelleher enabled auto-merge (squash) December 2, 2025 16:31
@leekelleher leekelleher merged commit 6104ae6 into umbraco:main Dec 2, 2025
28 checks passed
iOvergaard pushed a commit that referenced this pull request Dec 4, 2025
* Import missing component

* Handle nullable type

* Vertically center image

* Add minimum width for SVG without dimensions

* 100% height until max height

* 100% height minus top/bottom padding

* Revert "100% height minus top/bottom padding"

This reverts commit 67ada4c.

* Revert "Handle nullable type"

This reverts commit 3130e11.

* Removed flexbox style

* Fixed circular dependency

---------

Co-authored-by: leekelleher <leekelleher@gmail.com>
@iOvergaard
Copy link
Copy Markdown
Contributor

Picked for 16.5 with 9485a95

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.

Opening SVG media from media picker doesn't show preview (review pr)

6 participants