I’m migrating content from a Wordpress site to Strapi.
I’m making API calls to create entries (articles in this case).
Everything seems to be importing fine except the images that are supposed to be displayed in the body, are not displaying.
What I’m doing is:
-
Download images from the original Wordpress site.
-
In the body of an article, change img src attribute. For example, if in the wordpress article, the src attribuute of an image element was
"https://www.my-website.com/wp-uploads/image1.jpeg"
, I’m changing it to be"/uploads/image1.jpeg"
. Convert content usingnode-html-markdown
:
NodeHtmlMarkdown.translate(postData.body)
-
upload article content (works fine)
-
use
/api/upload
method and upload images to Strapi in FormData (it works fine, they are in the api assets folder in the Admin area of Strapi)
I’ve tried appending these to formData:
formData.append('refId', articleId);
formData.append('ref', 'api::article.article');
formData.append('field', 'body');
The relation gets saved to the database but the images are still not displaying in the body
In the schema.json that defines the article entry we have this definition of the ‘body’ field:
"body": {
"type": "customField",
"options": {
"output": "Markdown",
"preset": "standard"
},
"customField": "plugin::ckeditor.CKEditor",
"required": true
},
The body that gets saved to the Strapi database is in this format:
Some article text


Also, I need to get images to be displayed in the Text Editor when you edit an article.
How can I link images to an article, and display them?