stuffedtiger1
stuffedtiger1

Reputation: 73

Contentful: Why are Embedded Assets in Rich Text represented inconsistently in Content JSON?

I have a Gatsby-Contentful site I am currently developing, and I have two posts on Contentful which contain Embedded Assets in the Rich Text fields of each post.

In one Rich Text field, this embedded asset appears as follows:

{
"data": {
                      "target": {
                        "sys": {
                          "space": {
                            "sys": {
                              "type": "Link",
                              "linkType": "Space",
                              "id": "aw0p4zkj7lhv"
                            }
                          },
                          "id": "c5N0u9h6AksECP8JZEzOe1D",
                          "type": "Asset",
                          "createdAt": "2019-07-29T11:48:08.826Z",
                          "updatedAt": "2019-07-29T11:48:08.826Z",
                          "environment": {
                            "sys": {
                              "id": "master",
                              "type": "Link",
                              "linkType": "Environment"
                            }
                          },
                          "revision": 1
                        },
                        "fields": {
                          "title": {
                            "en-US": "dummy"
                          },
                          "description": {
                            "en-US": "dummy so api works"
                          },
                          "file": {
                            "en-US": {
                              "url": "//images.ctfassets.net/aw0p4zkj7lhv/5N0u9h6AksECP8JZEzOe1D/af219e63f6e381c7124a6d65a0fe85e0/test.jpg",
                              "details": {
                                "size": 58342,
                                "image": {
                                  "width": 1000,
                                  "height": 666
                                }
                              },
                              "fileName": "test.jpg",
                              "contentType": "image/jpeg"
                            }
                          }
                        }
                      }
                    },
                    "content": [],
                    "nodeType": "embedded-asset-block"
                  }
}

while in another post's Rich Text field it is missing a lot of the data:

{
"data": {
                      "target": {
                        "sys": {
                          "id": "c5N0u9h6AksECP8JZEzOe1D",
                          "type": "Link",
                          "linkType": "Asset"
                        }
                      }
                    },
                    "content": [],
                    "nodeType": "embedded-asset-block"
                  }
}

Why is there such a discrepancy, when I have embedded the images in both Rich Text fields in exactly the same way?

Upvotes: 0

Views: 1403

Answers (2)

Vinicius Cardoso
Vinicius Cardoso

Reputation: 1084

This happens because your cached files not correctly updated during the rebuild.

Just install Gatsby CLI with npm install -g gatsby-cli

Then gatsby clean

Then gatsby develop

Upvotes: 0

cointilt
cointilt

Reputation: 728

When ever this happens to me, I usually have to remove the cache (root/.cache) and public (root/public) folders and restart the server to get the correct data from Contentful.

Upvotes: 1

Related Questions