<p>Also run the content through the <code>|raw</code> 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.</p>

CC BY-SA 4.0
2019-11-04T15:35:55.893Z
2019-11-04T15:35:55.893Z
gdubois
<p>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.</p>

<p>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.</p>

<p>My code:</p>

<pre><code>&lt;root&gt;
{% for entry in craft.entries.section('articlesAndExcerpts').status('not foo').limit(1) %}
  &lt;entry&gt;

    &lt;title&gt;&lt;![CDATA[{{ entry.title }}]]&gt;&lt;/title&gt;

    {# more fields here #}

    &lt;body&gt;&lt;![CDATA[{{ entry.body|replace('src="https://memoirs.azrielifoundation.org/': 'src="/'}) }}]]&gt;&lt;/body&gt;

  &lt;/entry&gt;
{% endfor %}}
&lt;/root&gt;
</code></pre>

<p>With without the <code>|replace('')</code> 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:</p>

<p><a href="https://i.sstatic.net/3HVCF.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/3HVCF.jpg" alt="enter image description here"></a></p>

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

<plugin-feedme>
Importing Entries from Craft 2 to Craft 3 with Feed Me - find/replace twig filter issues
# Importing Entries from Craft 2 to Craft 3 with Feed Me - find/replace twig filter issues

(Asked by: username_0 on 2019-11-01)

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) %}
  

    {{ entry.title }}

    {# more fields here #}

    {{ entry.body|replace('src="https://memoirs.azrielifoundation.org/': 'src="/'}) }}

  
{% 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:

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

**Tags:** plugin-feedme

---

## 1 answers

### Answer by username_1 on 2019-11-04. Score: 2 | Accepted answer

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.


---

