跳转到内容
本站为社区维护的非官方中文翻译,与 Cloudflare, Inc. 无关联。本站不提供账户登录,请勿在任何非官方站点输入您的 Cloudflare 账户信息。官方文档:developers.cloudflare.com

启用灵活变体

最后更新 查看 MarkdownAgent 设置

灵活变体允许您创建具有动态调整大小的变体,可提供比常规变体更多的选项。默认情况下未启用此选项。

通过 Cloudflare 仪表板启用灵活变体

  1. 在 Cloudflare 仪表板中,转到 Hosted Images(托管图像) 页面。

    前往 Hosted images(托管图像) ↗
  2. 选择 Delivery(交付) 标签。

  3. 启用 Flexible variants(灵活变体)。

通过 API 启用灵活变体

向 Update a variant endpoint 发出 PATCH 请求。

curl --request PATCH https://api.cloudflare.com/client/v4/accounts/{account_id}/images/v1/config \
--header "Authorization: Bearer <API_TOKEN>" \
--header "Content-Type: application/json" \
--data '{"flexible_variants": true}'

激活后,您可以在任何 Cloudflare 图像上使用优化参数。例如,

https://imagedelivery.net/{account_hash}/{image_id}/w=400,sharpen=3

这篇文档对您有帮助吗?