gpt4 book ai didi

graphql - 在 Strapi GraphQL 查询中获取图像格式

转载 作者:行者123 更新时间:2023-12-03 19:09:21 25 4
gpt4 key购买 nike

我有一个 Post内容类型,具有 FeaturedImage field 。由于此字段是图像上传,因此 Strapi 会生成方便的附加格式:thumbnail , small , mediumlarge .
当我在 JSON 中查询所有帖子时,我在响应中得到这些格式:

{
"id": 1,
"Title": "Hello World",
"Content": "Nullam id dolor id nibh ultricies vehicula ut id elit..",
"FeaturedImage": {
"id": 1,
"name": "angel-jimenez-168185",
"alternativeText": "",
"caption": "",
"width": 2768,
"height": 1560,
"formats": {
"thumbnail": {
"hash": "thumbnail_angel_jimenez_168185_aaceac7acf",
"ext": ".jpeg",
"mime": "image/jpeg",
"width": 245,
"height": 138,
"size": 6.22,
"path": null,
"url": "/uploads/thumbnail_angel_jimenez_168185_aaceac7acf.jpeg"
},
"large": {
"hash": "large_angel_jimenez_168185_aaceac7acf",
"ext": ".jpeg",
"mime": "image/jpeg",
"width": 1000,
"height": 564,
"size": 75.71,
"path": null,
"url": "/uploads/large_angel_jimenez_168185_aaceac7acf.jpeg"
},
"medium": {
"hash": "medium_angel_jimenez_168185_aaceac7acf",
"ext": ".jpeg",
"mime": "image/jpeg",
"width": 750,
"height": 423,
"size": 41.8,
"path": null,
"url": "/uploads/medium_angel_jimenez_168185_aaceac7acf.jpeg"
},
"small": {
"hash": "small_angel_jimenez_168185_aaceac7acf",
"ext": ".jpeg",
"mime": "image/jpeg",
"width": 500,
"height": 282,
"size": 19.69,
"path": null,
"url": "/uploads/small_angel_jimenez_168185_aaceac7acf.jpeg"
}
}
}
}
但是,如果我在 GraphQL 中查询,只有 publicURL对于原始(全尺寸)图像可用:
GraphQL image format tree
我如何使用 GraphQL 访问这些图像格式?

最佳答案

此查询向我显示了所有预期的格式对象:

query MyQuery {
strapi {
home {
content {
image {
formats
}
}
}
}
}
我确实在trapi上明确安装了graphql插件
https://strapi.io/documentation/3.0.0-beta.x/plugins/graphql.html#usage
我在我的 api url 中使用/graphql(例如 http://localhost:1337/graphql)。
我希望有帮助,@jgthms
供引用
表带 v.3.1.4
Strapi-plugin-graphql v.3.1.4

关于graphql - 在 Strapi GraphQL 查询中获取图像格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62662953/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com