Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ian 5 posts 104 karma points
    Nov 25, 2022 @ 02:06
    Ian
    0

    Media Picker with SVG in Umbraco 10

    For the life of me I cannot retrieve an SVG (Vector Graphics (SVG)) in my views/models. I have created a picker (using Umbraco.MediaPicker3) with no restrictions. I have attached it to my document type.

    I can create a content node, and pick a JPG. Works fine. Pick a PDF? Works fine. These all return a MediaWithCrops object. Pick an SVG? Returns null.

    I can't see any documentation about treating SVG differently. Any hints? The picker shows the SVG preview correctly: Media Picker showing preview of SVG icon

    If I do something like this:

    var entry = (MyCustomModel)Model.Content;
    var icon = entry.Icon;
    var sourceValue = Model.Content.GetProperty("icon").GetSourceValue();
    

    I can see for a random media entry (PDF in this case): Visual Studio debug properties showing a valid icon and sourcevalue

    And if I try the same again with an SVG, icon is now null but there is a SourceValue present: Visual Studio debug properties showing a null icon but sourcevalue is present

  • Ian 5 posts 104 karma points
    Nov 25, 2022 @ 05:06
    Ian
    100

    There was something magic about the folder they were in. I created another folder of the exact same media type, moved the same images across, and it worked. 🙄

Please Sign in or register to post replies

Write your reply to:

Draft