灵活变体允许您创建具有动态调整大小的变体,可提供比常规变体更多的选项。默认情况下未启用此选项。
-
在 Cloudflare 仪表板中,转到 Hosted Images(托管图像) 页面。
Go to Hosted images ↗ -
选择 Delivery(交付) 标签。
-
启用 Flexible variants(灵活变体)。
向 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