robin-image-optimizer
/
libs
/
addons
/
includes
/
classes
/
format
/
class-format-converter-avif.php
class-format-converter-api.php
3 months ago
class-format-converter-avif.php
5 months ago
class-format-converter-factory.php
5 months ago
class-format-converter-webp.php
5 months ago
class-format-converter-avif.php
61 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * AVIF format converter implementation. |
| 5 | * |
| 6 | * Converts images to AVIF format using the Robin Image Optimizer API. |
| 7 | * AVIF provides superior compression compared to WebP but requires premium license. |
| 8 | * |
| 9 | * @author Alexander Teshabaev <sasha.tesh@gmail.com> |
| 10 | */ |
| 11 | class WRIO_Format_Converter_AVIF extends WRIO_Format_Converter_Api { |
| 12 | |
| 13 | /** |
| 14 | * Get the format name. |
| 15 | * |
| 16 | * @return string |
| 17 | */ |
| 18 | protected function get_format_name() { |
| 19 | return 'avif'; |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Get the file extension for AVIF format. |
| 24 | * |
| 25 | * @return string |
| 26 | */ |
| 27 | protected function get_file_extension() { |
| 28 | return '.avif'; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Get the MIME type for AVIF format. |
| 33 | * |
| 34 | * @return string |
| 35 | */ |
| 36 | protected function get_mime_type() { |
| 37 | return 'image/avif'; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Get API query parameters for AVIF conversion. |
| 42 | * |
| 43 | * @param bool $quota Whether to include quota-related parameters. |
| 44 | * |
| 45 | * @return array Query parameters for the API request. |
| 46 | */ |
| 47 | protected function get_api_query_params( $quota ) { |
| 48 | // AVIF does not use 'type' parameter per requirements |
| 49 | return [ 'format' => 'avif' ]; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Check if AVIF format is available for free tier users. |
| 54 | * |
| 55 | * @return bool False - AVIF requires premium license. |
| 56 | */ |
| 57 | protected function is_free_tier_supported() { |
| 58 | return false; |
| 59 | } |
| 60 | } |
| 61 |