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 29 posts 213 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 1929 posts 6697 karma points MVP 2x c-trib
    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 29 posts 213 karma points
    Feb 15, 2021 @ 14:24
    Jorge Ribeiro
    0

    Makes sense!

    Thanks!!

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Jan 08, 2024 @ 13:05
    Simon Dingley
    0

    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

    Whilst I accept that this post was made some time ago it is still relevant to a task I am working on now. I don't believe this statement to be correct since the URLs in the RTE should remain as they have always been and will be returned as relative or absolute when a request is made.

Please Sign in or register to post replies

Write your reply to:

Draft