Copied to clipboard

Flag this post as spam?

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


  • Jorge Ribeiro 25 posts 208 karma points
    Feb 15, 2021 @ 11:00
    Jorge Ribeiro
    0

    RTE transform local urls to absolute

    Hi

    I'm creating a newsletter using my umbraco site's backoffice. I created a custom section where editors can add content to the newsletter using RTE. This content is saved in a custom DB but can reference site content.

    The problem arrises when editors, in RTE, add a link for a site's content. RTE witll render it locally, with {locallink:umb} etc attrs, but I reealy need all URLs to be absolute ones.

    Using bellow statment I managed to get relative paths but still need absolute ones because the newsletter is to be sent by email and all links must be absolute.

    var content =  new HtmlLocalLinkParser(base.UmbracoContextAccessor).EnsureInternalLinks(rteArticle);
    
    // Change from 
    // href="/{localLink:umb://media/14508b4c10c64f8586bcbb0e933f38fd}"
    // to
    // href="/media/ksffafgg/wp216_en.pdf"
    // but need
    // href="https://www.mysite.com/media/ksffafgg/wp216_en.pdf"
    

    Does umbraco have tools to change this or do I have to parse RTE text by myself changing element's href and src?

    Regards,

    Jorge

  • Huw Reddick 335 posts 1007 karma points
    Feb 15, 2021 @ 13:33
    Huw Reddick
    100

    I would expect you need to do it manually, I would not expect this behavior to be normal since you would not be able to move content from say dev to prod if url's were absolute not relative

    I would parse the rte content prior to emailing it out.

  • Jorge Ribeiro 25 posts 208 karma points
    Feb 15, 2021 @ 14:24
    Jorge Ribeiro
    0

    Makes sense!

    Thanks!!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" button below.

    Continue discussion

Please Sign in or register to post replies