Advanced conditional transformations for video
Last updated: Jun-09-2026
A conditional transformation embeds a transformation directly within a condition in your URL or SDK call, using the format if_condition/transformation/if_end. For the basics of this syntax and worked examples, see Specifying transformations for a condition. For details on the conditions themselves, see Specifying conditions.
This page covers advanced techniques: combining multiple conditions with AND/OR logic, and defining fallback transformations using else branches.
Multiple AND | OR conditions
You can specify multiple conditions to evaluate by joining the conditions with 'AND' or 'OR' conjunction operators.
The example below checks whether the video's aspect ratio is larger than a standard mobile portrait orientation AND if it has a large width. Only in this case, it crops the video to a portrait orientation with a width of 500. If the video already has a portrait orientation (condition 1 is false) or if the original width is less than 500 (condition 2 is false), the conditional transformation is ignored and the video is delivered in its original shape and size.
if...end_if chained components in the URL.Else branch transformations
You can specify a transformation that is applied in the case that the initial condition is evaluated as false (and hence the transformations associated with the condition are not applied), by using the if_else parameter to specify this fallback transformation.
For example, the following conditional transformation checks whether a video's aspect ratio is close to the desired aspect ratio. If it is close, any necessary padding when the video is resized uses a black background. If the aspect ratio is much smaller (for example, a square or portrait video), a blurred video padding is added instead.
In cases where the if condition is not in the preceding transformation component, then the if_else parameter also acts as an if_end parameter: all chained transformation components until the one with if_else are only applied if the previous condition holds true. Multiple conditional transformations can also be applied by adding an if_end parameter to the last transformation component in the chain, and to avoid ambiguity, the component with the if_else parameter should not have additional transformation instructions.
For example, if the video is shorter than or equal to 10 seconds, fade in for one second and fade out for one second. If the video is longer than 10 seconds, fade in for two seconds and fade out for two seconds:
- Specifying conditions: Learn how to define conditions based on video characteristics, operators, and parameters.
- Specifying transformations for a condition: Learn the syntax for applying transformations when a condition is met, including chained transformations and worked examples.