Description:
This article explains how to use the force_format parameter to control image delivery in specific formats. With force_format, users can enforce a preferred file format, such as WebP, JPG, or PNG, for optimized image delivery. While WebP is highly efficient in reducing file sizes, other formats might be more suitable for specific cases. The force_format parameter options allow users to select the desired format based on needs, balancing flexibility with strict format delivery.
Parameter Options:
The force_format parameter can be set to various formats, including WebP, JPG, and PNG, by appending it directly to the image URL.
Below are examples of how to use force_format with different formats:
1- force_format=webp
- This parameter enforces WebP delivery when added directly to the image URL.
In some rare cases, the WebP compression algorithms may produce a WebP file which has bigger filesize than the corresponding JPG resizing. In such cases the system will deliver JPG as final output (but your asset will be better optimized) - Recommended: This option is more flexible and "smart" because it automatically optimizes delivery for the smallest file size.
2- force_format=_webp
- This parameter strictly enforces WebP delivery, even if the resulting WebP file is larger than the original format.
- This option should be used only when WebP delivery is mandatory, as it may impact performance by delivering larger files.
3- force_format=jpg or force_format=png
- These parameters enforce JPG or PNG delivery, respectively, ensuring images are delivered in the specified format.
Format "chaining" with force_format:
The force_format option also supports chaining multiple preferred formats for delivery.
For example, you can specify multiple formats in a priority order, such as force_format=webp,jpg,png.
If WebP is not supported by the requestor (due to software limitations or older browser versions), the system will attempt to deliver the image in the next available format in the chain.
Examples:
- Example 1: https://token.cloudimg.io/sample.li/paris.jpg?w=400&force_format=webp
This will deliver the image in WebP format, if the WebP file size is smaller than the JPG. If not, it will be delivered as JPG. - Example 2: https://token.cloudimg.io/sample.li/paris.jpg?w=400&force_format=_webp
This enforces WebP delivery even if the WebP file size is larger than JPG, ensuring WebP format delivery regardless of file size.
- Example 3: https://token.cloudimg.io/sample.li/paris.jpg?w=400&force_format=webp,jpg,png
This will deliver the image in WebP format by default. If WebP is unsupported by the requestor, it will fall back to JPG, and if JPG is also unsupported, it will deliver in PNG format. - Example 4: https://token.cloudimg.io/sample.li/paris.jpg?w=400&force_format=jpg
This will deliver the image in JPG format - Example 5: https://token.cloudimg.io/sample.li/paris.jpg?w=400&force_format=png
This will deliver the image in PNG format
Additional Notes:
- We recommend using force_format=webp for most cases, as it prioritizes the smallest file size.
- Use force_format=_webp cautiously, as it bypasses size optimization and can impact performance.
Need Assistance?
If you have any questions or encounter issues, please feel free to contact our Support Team. When reaching out, include the following details for a quicker resolution:
- Token
- Brief description of the issue (including URLs, screenshots, or short videos if available)
- Steps to reproduce the issue
Comments
Please sign in to leave a comment.