if-else
- like constructs within an asset URL.ar
(aspect ratio) property of an image helps determine whether it has a landscape (> 1) or portrait (< 1) orientation.if-{property}_{operator}_{value}
. Read moreif-else
are optional and can be skipped.condition
part in the above syntax can be built using a predefined set of image properties, comparison operators, and logical operators. A singular condition follows the {property}_{operator}_{value}
syntax. For example, if-h_gt_100
evaluates to true if the height of the image is greater than 100.and
and or
logical operators. For example, if-h_gte_100_and_h_lte_400_or_ar_lt_4-3
evaluates to true only if the image height is between 100 and 400, or the aspect ratio is less than 4:3.and
operator has precedence over or
operator during condition evaluation.h_eq_100
evaluates to true if the image height is equal to 100h_ne_100
evaluates to true if the image height is not equal to 100h_gt_100
evaluates to true if the image height is greater than 100h_gte_100
evaluates to true if the image height is greater than or equal to 100h_lt_100
evaluates to true if the image height is less than 100h_lte_100
evaluates to true if the image height is less than or equal to 100if-else
and the succeeding transformations are optional.if-ar_gt_1,w-200,if-else,w-300,if-end
and if-ar_gt_1,w-200,if-end
are both valid.h-200,c-pad_resize:if-h_eq_200,w-100,if-end:rt-90
, the if block is the second step in a chain of three steps. The height value that this, if block receives for evaluating the h_eq_100
condition, will be 200 since the previous step in the chain resizes the image to a height of 200. Hence, the condition will evaluate to true.h-400:rt-90,if-h_eq_200,w-100,if-end:rt-90
or h-400:if-h_eq_200,w-100,if-end,bl-10:rt-90
or h-100,if-h_eq_200,w-100,if-end
are all invalid.