Copied to clipboard

Flag this post as spam?

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


  • Nikolaj Herting Olsen 5 posts 75 karma points notactivated
    Dec 16, 2022 @ 12:41
    Nikolaj Herting Olsen
    0

    Media items referenced by richtext editor through macros

    We've got a project with a couple of macros to use in RichText Editor.

    Specifically this simple one, which is used to add buttons for internal/external links or media items.

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    @{
        var links = Model.GetParameterValueAsLinks("links");
    }
    
    @if (links != null)
    {
        foreach (var link in links)
        {
            <a class="a-button u-bg-color--secondary" href="@Html.Raw(link.Url)" target="@link.Target">@link.Name</a>
        }
    }
    

    The problem is that when you choose a media item, the media item will not show it being used in media archive, which in turn results in web editors deleting media items that looks like they're not in use, but really are.

    Example of media item showing it being used. Example of media item showing it being used. I have tried to include data-udi in the tag, but unfortunately without luck. (<a data-udi="umb://media/10b31c0f862244fbbcbb51f4a48bbcf8" href="...)

    Couldn't find any information about this, is it even possible to create the reference when used through a macro?

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Dec 16, 2022 @ 13:37
    Huw Reddick
    0

    Hi Nikolaj,

    Unfortunately I don't believe it is possible, you would probably need to write a custom angular plugin to do it as you would need to parse the macro data.

  • Nikolaj Herting Olsen 5 posts 75 karma points notactivated
    Dec 16, 2022 @ 14:01
    Nikolaj Herting Olsen
    0

    Hi Huw.

    Thank you for such a quick reply!

    Would be nice if it worked with macros, since it does through the build-in link and media picker through richtext. Perhaps some day :) richtext editor toolbar I will update if i find a fairly simple way to code it.

    Have a great weekend!

Please Sign in or register to post replies

Write your reply to:

Draft