umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.39k stars 2.66k forks source link

Svg thumbnails/previews are not rendered outside of the media secion #16758

Open Migaroez opened 1 month ago

Migaroez commented 1 month ago

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

14.1.0-rc2

Bug summary

Can only see the content of an image in the media item workspace (probably not the right name)

Specifics

Example url of a document with 2 pickers https://localhost:44394/umbraco/section/content/workspace/document/edit/095e57cc-2d9a-4286-b133-abb5ab050e00/invariant/view/content/tab/content image

Preview https://localhost:44394/umbraco/section/content/workspace/document/edit/095e57cc-2d9a-4286-b133-abb5ab050e00/invariant/view/content/tab/content/modal/umb-modal-imagecroppereditor/allimages/invariant/51a1b9c8-6d7d-45ec-b11a-d9679146131e/ image

Media workspace inside infinite editing https://localhost:44394/umbraco/section/content/workspace/document/edit/095e57cc-2d9a-4286-b133-abb5ab050e00/invariant/view/content/tab/content/modal/umb-modal-imagecroppereditor/allimages/invariant/51a1b9c8-6d7d-45ec-b11a-d9679146131e/modal/umb-modal-workspace/media/edit/9ace92ec-7b3c-4ad3-87f0-ebe4dbf823c8/invariant/view/media image

Media library + edit https://localhost:44394/umbraco/section/media/view/media/collection/grid/modal/umb-modal-workspace/media/edit/5fb246b0-729f-41d2-85c4-c644a323e91c/invariant/view/media image

Media workspace straight from the tree https://localhost:44394/umbraco/section/media/workspace/media/edit/5fb246b0-729f-41d2-85c4-c644a323e91c/invariant/view/media image

Steps to reproduce

Expected result / actual result

All examples specified should render at least a thumbnail of the SVG

iOvergaard commented 1 month ago

@Migaroez I looked into this issue. We are calling the endpoint of /umbraco/management/api/v1/imaging/resize/urls for all picked media items in case that a thumbnail is available. For SVGs, we do not get a media URL back on this endpoint, so it ends up being shown as an icon.

I don't think we can get the actual media URL (the umbracoFile property) at this point. We simply don't have that data. And since .svg is not considered an image resource on the backend, the endpoint above will never return anything.

I guess that we should add an exception specifically for SVGs in the backend. We want to treat them as images in the Backoffice client, so for us, it makes no difference that they happen to have an .svg extension. They render just fine in an <img> element.

What do you think?

Migaroez commented 1 month ago

Yeah sounds reasonable, I will have a look at the code to see how feasible it is.

Migaroez commented 1 month ago

I had a look at this and it seems like the requirements for the endpoint were not fully fleshed out when it was created. I will bring this up on the next team meeting.