I'm migrating content from an old Craft 2 site (2.6.2985) to a new Craft 3 site. Cannot do a strait upgrade for various reasons.

I've started to set up an XML feed to use Feedme with. I am running into one issue where the body redactor field has a lot of images in it and I want do a find and replace to remove the absolute url and replace with a relative url so images will load on the front end.

My code:

{% for entry in craft.entries.section('articlesAndExcerpts').status('not foo').limit(1) %}

    <title><![CDATA[{{ entry.title }}]]></title>

    {# more fields here #}

    <body><![CDATA[{{ entry.body|replace('src="https://memoirs.azrielifoundation.org/': 'src="/'}) }}]]></body>

{% endfor %}}

With without the |replace('') filter everything is good. However when I use the replace filter it replaces the url as expected but at the same time creates a lot of html entities, like this:

enter image description here

How can I prevent this from happening and still do a find/replace on the image urls?

1 Answer 1


Also run the content through the |raw filter to get rid of the html entities. I believe that it works without the replace filter because once that is run, twig is parsing the provided text.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.