Skip to documentation content

Image Preset

Image Preset

The image_preset object and methods for image presets.

{{ image_preset }}

Properties
Properties of {{ image_preset }} objects
Name Type Description
object_type string Will always be image_preset
is_valid boolean True if this references a published image_preset
guid string The unique identifier for this image_preset
value string Contains the same value as guid
code string The unique code for this image preset
query_string string The settings for this image preset represented as a query string
extension string The extension that filenames should end with for images that use this image preset, if it may be used to change the image format
settings {{ dictionary }} Contains all of the settings that this image preset will apply to images when used
field_id string The identifier for this field
label string The label for this field
output string The default output that the image_preset produces when output directly to the template, which is currently the preset code. The default output may change at any time. Template developers should avoid using this and should handle the output of image presets themselves
Example Load one image preset and read its code and query_string{% image_preset %} loads a single preset by code or GUID; code and query_string describe how the preset transforms images.
Liquid
{%- image_preset var thumb = "thumb" -%}
{%- if thumb.is_valid -%}
	<p>Preset {{ thumb.code }} → {{ thumb.query_string }} ({{ thumb.extension }})</p>
{%- endif -%}

{% image_preset %}

Identifies the image preset by its code rather than a name. Codes are matched without regard to case.

{% image_preset output_to_template? [[var, set, or assign]? variable_name]? output_to_template? = value %}
Parameters
output_to_template optionalflag
Include this flag to write the image_preset's output into the page at this point. What that output is differs by type, and for most types it is a built-in default that may change at any time, so see the output property of the image_preset object before relying on it. The flag may come before or after the variable name. When the call names no variable, the output is written whether or not the flag is present, which makes {% image_preset = value %} the smallest valid use of this method. When the call names a variable, the flag saves the image_preset to the variable and writes its output as well.
var, set, or assign optionalkeyword
Chooses the scope that holds the variable. var, the default, stores it in the current scope. set and assign can store it in outer scopes; Variable Scopes compares the three and when each fits.
variable_name optionalvariable
The variable that receives the image_preset. It may also be written as a reference, &name, which reads the variable's name from another variable (see Methods Overview). Leave it out to write the image_preset to the template instead.
value requiredexpression
Required; without a value the method call is not valid. Identifies which image_preset to fetch. It can evaluate to the image_preset itself, to its GUID, or to other text that identifies it, which for most types is its name; a type identified some other way, or only by GUID, says so in its summary. Names are matched without regard to case, but accented letters must match. A GUID identifies exactly one record, whereas when several records share a name, which of them is returned is not specified, so giving the records you fetch by name unique names avoids the question. A name reads better in a template and a GUID is exact; neither suits every site. When nothing matches, no error is raised: the variable holds an invalid image_preset, whose is_valid is false, so check is_valid before using it. When the expression itself has no value, for example an undefined variable, the method does nothing and the variable keeps any earlier value. May use liquid filters.

Fetches a single {{ image_preset }}.

Example Load one image preset and read its code and query_string{% image_preset %} loads a single preset by code or GUID; code and query_string describe how the preset transforms images.
Liquid
{%- image_preset var thumb = "thumb" -%}
{%- if thumb.is_valid -%}
	<p>Preset {{ thumb.code }} → {{ thumb.query_string }} ({{ thumb.extension }})</p>
{%- endif -%}