variants
Creates, updates, deletes, gets or lists a variants resource.
Overview
| Name | variants |
| Type | Resource |
| Id | cloudflare.images.variants |
Fields
The following fields are returned by SELECT queries:
- get
- list
Variant details response
| Name | Datatype | Description |
|---|---|---|
variant | object |
List variants response
| Name | Datatype | Description |
|---|---|---|
variants | object |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | variant_id, account_id | Fetch details for a single variant. | |
list | select | account_id | Lists existing variants. | |
create | insert | account_id, id, options | Specify variants that allow you to resize images for different use cases. | |
edit | update | variant_id, account_id, options | Updating a variant purges the cache for all images associated with the variant. | |
delete | delete | variant_id, account_id | Deleting a variant purges the cache for all images associated with the variant. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
account_id | string | The Cloudflare account ID. |
variant_id | string |
SELECT examples
- get
- list
Fetch details for a single variant.
SELECT
variant
FROM cloudflare.images.variants
WHERE variant_id = '{{ variant_id }}' -- required
AND account_id = '{{ account_id }}' -- required
;
Lists existing variants.
SELECT
variants
FROM cloudflare.images.variants
WHERE account_id = '{{ account_id }}' -- required
;
INSERT examples
- create
- Manifest
Specify variants that allow you to resize images for different use cases.
INSERT INTO cloudflare.images.variants (
id,
neverRequireSignedURLs,
options,
account_id
)
SELECT
'{{ id }}' /* required */,
{{ neverRequireSignedURLs }},
'{{ options }}' /* required */,
'{{ account_id }}'
RETURNING
errors,
messages,
result,
success
;
# Description fields are for documentation purposes
- name: variants
props:
- name: account_id
value: "{{ account_id }}"
description: Required parameter for the variants resource.
- name: id
value: "{{ id }}"
- name: neverRequireSignedURLs
value: {{ neverRequireSignedURLs }}
description: |
Indicates whether the variant can access an image without a signature, regardless of image access control.
default: false
- name: options
description: |
Allows you to define image resizing sizes for different use cases.
value:
fit: "{{ fit }}"
height: {{ height }}
metadata: "{{ metadata }}"
width: {{ width }}
UPDATE examples
- edit
Updating a variant purges the cache for all images associated with the variant.
UPDATE cloudflare.images.variants
SET
neverRequireSignedURLs = {{ neverRequireSignedURLs }},
options = '{{ options }}'
WHERE
variant_id = '{{ variant_id }}' --required
AND account_id = '{{ account_id }}' --required
AND options = '{{ options }}' --required
RETURNING
errors,
messages,
result,
success;
DELETE examples
- delete
Deleting a variant purges the cache for all images associated with the variant.
DELETE FROM cloudflare.images.variants
WHERE variant_id = '{{ variant_id }}' --required
AND account_id = '{{ account_id }}' --required
;