如何使用自然宽度(分辨率)从 contentful 中获取图像?

How to get images from contentful using the natural width (resolution)?

我在 Contentful 中有各种尺寸的图片,即宽度为 200px、600px、800px、1000px 等

如果我根据 gatsby.js 文档使用 responsiveresolution,它将提高我的小图像的分辨率:

allContentfulProduct {
    edges {
      node {
        id
        productName
        image {
          responsiveResolution(width: 600) {
            width
            height
            src
            srcSet
          }
        }
      }
    }
  }
}

如何从 Contentful 获得图像的自然分辨率? responsiveresolution in gatsby.js 可以使用更好的文档!

您可以通过运行此查询获得自然分辨率。

allContentfulProduct {
    edges {
      node {
        id
        productName
        image {
          file{
            url
          }
        }
      }
    }
  }
}

responsiveResolution 只是一个帮手,您完全可以在没有它的情况下像查询任何其他条目一样查询图像。