gatsby-uc / plugins

Monorepo for plugins in the Gatsby User Collective.
https://gatsbyuc.dev
MIT License
58 stars 34 forks source link

bug(gatsby-strapi-source): With external and Strapi images in Markdown, some Strapi images are missing/blended #425

Open hrenaud opened 1 year ago

hrenaud commented 1 year ago

Describe the bug

When I add some images in a Markdown field in Strapi, if I use external images (https://domain.tld/image.png) and Strapi images, the medias array doesn't contain / blend data for some images.

To Reproduce

Copy/adapt this snippet into your richtext.

## External image
![Internet img](https://raw.githubusercontent.com/NovaGaia/strapi-plugin-mock-datas/main/docs/Capture-2023-04-15-102849.png)

## Strapi Image
![Strapi img 1](/uploads/Capture_d_ecran_2022_10_22_192013_1_f3850ccdca.png)

![Strapi img 2](/uploads/lac_1_ceb35aeb78.png)

Result of medias

[
    {
        "alternativeText": "Internet img",
        "file": {
            "alternativeText": ""
        },
        "localFile": {
            "childImageSharp": {
                "gatsbyImageData": {
                    "layout": "constrained",
                    "backgroundColor": "#384868",
                    "images": {
                        "fallback": {
                            "src": "/static/cc395cbe6efc81c57d440d2c13c94fda/e2861/Capture_d_ecran_2022_10_22_192013_1_f3850ccdca.png",
                            "srcSet": "/static/cc395cbe6efc81c57d440d2c13c94fda/13424/Capture_d_ecran_2022_10_22_192013_1_f3850ccdca.png 256w,\n/static/cc395cbe6efc81c57d440d2c13c94fda/37319/Capture_d_ecran_2022_10_22_192013_1_f3850ccdca.png 512w,\n/static/cc395cbe6efc81c57d440d2c13c94fda/e2861/Capture_d_ecran_2022_10_22_192013_1_f3850ccdca.png 1023w",
                            "sizes": "(min-width: 1023px) 1023px, 100vw"
                        },
                        "sources": [
                            {
                                "srcSet": "/static/cc395cbe6efc81c57d440d2c13c94fda/0c128/Capture_d_ecran_2022_10_22_192013_1_f3850ccdca.webp 256w,\n/static/cc395cbe6efc81c57d440d2c13c94fda/5d10f/Capture_d_ecran_2022_10_22_192013_1_f3850ccdca.webp 512w,\n/static/cc395cbe6efc81c57d440d2c13c94fda/b724a/Capture_d_ecran_2022_10_22_192013_1_f3850ccdca.webp 1023w",
                                "type": "image/webp",
                                "sizes": "(min-width: 1023px) 1023px, 100vw"
                            }
                        ]
                    },
                    "width": 1023,
                    "height": 575
                }
            }
        },
        "src": "https://raw.githubusercontent.com/NovaGaia/strapi-plugin-mock-datas/main/docs/Capture-2023-04-15-102849.png",
        "url": "https://raw.githubusercontent.com/NovaGaia/strapi-plugin-mock-datas/main/docs/Capture-2023-04-15-102849.png"
    },
    {
        "alternativeText": "Strapi img 1",
        "file": {
            "alternativeText": null
        },
        "localFile": {
            "childImageSharp": {
                "gatsbyImageData": {
                    "layout": "constrained",
                    "backgroundColor": "#f8f8f8",
                    "images": {
                        "fallback": {
                            "src": "/static/5c012d011772fa184e4d1bc971ecf887/cd293/lac_1_ceb35aeb78.png",
                            "srcSet": "/static/5c012d011772fa184e4d1bc971ecf887/78e2e/lac_1_ceb35aeb78.png 256w,\n/static/5c012d011772fa184e4d1bc971ecf887/90381/lac_1_ceb35aeb78.png 512w,\n/static/5c012d011772fa184e4d1bc971ecf887/cd293/lac_1_ceb35aeb78.png 1023w",
                            "sizes": "(min-width: 1023px) 1023px, 100vw"
                        },
                        "sources": [
                            {
                                "srcSet": "/static/5c012d011772fa184e4d1bc971ecf887/344d9/lac_1_ceb35aeb78.webp 256w,\n/static/5c012d011772fa184e4d1bc971ecf887/e0e76/lac_1_ceb35aeb78.webp 512w,\n/static/5c012d011772fa184e4d1bc971ecf887/f7bc7/lac_1_ceb35aeb78.webp 1023w",
                                "type": "image/webp",
                                "sizes": "(min-width: 1023px) 1023px, 100vw"
                            }
                        ]
                    },
                    "width": 1023,
                    "height": 682
                }
            }
        },
        "src": "/uploads/Capture_d_ecran_2022_10_22_192013_1_f3850ccdca.png",
        "url": "http://localhost:1337/uploads/Capture_d_ecran_2022_10_22_192013_1_f3850ccdca.png"
    }
]

Expected behavior

I'm waiting for an array with 3 images, with data who aren't blended.

System Info

Please provide information about your site via these means as possible:

soichiro0210 commented 1 year ago

This may be slightly different from this issue, but in my case, I found that when I created a component that contained media type, the contents were not fetched. For components that do not contain media type, there was no problem.