Flexible variants を使うと、動的リサイズのバリアントを作成できます。通常のバリアントより選択肢が増えます。このオプションはデフォルトでは無効です。
-
Cloudflare ダッシュボードで Hosted Images ページを開きます。
Hosted images を開く ↗ -
Delivery タブを選択します。
-
Flexible variants を有効にします。
バリアントを更新するエンドポイント に 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