759 lines
33 KiB
PHP
759 lines
33 KiB
PHP
<?php
|
|
use X13Webp\Core\Configurator\ConfiguratorBase;
|
|
|
|
$translations_name = 'form';
|
|
|
|
$fields_form = array();
|
|
|
|
$ssl = false;
|
|
|
|
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") {
|
|
// jeśli weszliśmy z https (nawet jeśli sklep nie ma włączonego SSL)
|
|
$ssl = true;
|
|
}
|
|
|
|
$shop = Context::getContext()->shop;
|
|
|
|
$base = ($ssl ? 'https://' . $shop->domain_ssl : 'http://' . $shop->domain);
|
|
|
|
$search_products_url = $base . __PS_BASE_URI__ . 'modules/' . $this->name . '/ajax_products_list.php?token=' . $this->getProductsAjaxToken();
|
|
|
|
$convert_image_url = $this->context->link->getAdminLink('AdminX13WebpConverter'). '&ajax=1&action=convertImage';
|
|
$product_image_url = $this->context->link->getAdminLink('AdminX13WebpConverter'). '&ajax=1&action=getProductImage';
|
|
|
|
if($ssl){
|
|
$convert_image_url = str_replace('http://', 'https://', $convert_image_url);
|
|
$product_image_url = str_replace('http://', 'https://', $product_image_url);
|
|
}
|
|
|
|
$fields_form[] = array(
|
|
'form' => array(
|
|
'legend' => array(
|
|
'title' => static::getTranslationByKey('Settings'),
|
|
'icon' => 'icon-cogs',
|
|
),
|
|
'input' => array(
|
|
array(
|
|
'type' => 'switch',
|
|
'label' => $this->l('Enable support for WebP', $translations_name),
|
|
'name' => $this->options_prefix . 'WEBP_SUPPORT_ENABLE',
|
|
'values' => array(
|
|
array(
|
|
'id' => 'WEBP_SUPPORT_ENABLE_on',
|
|
'value' => 1,
|
|
'label' => $this->l('Yes', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 'WEBP_SUPPORT_ENABLE_off',
|
|
'value' => 0,
|
|
'label' => $this->l('No', $translations_name),
|
|
),
|
|
),
|
|
'default' => 1
|
|
),
|
|
array(
|
|
'type' => 'switch',
|
|
'label' => $this->l('Enable WebP for new products categories etc.', $translations_name),
|
|
'name' => $this->options_prefix . 'WEBP_AUTO_GENERATOR_ENABLE',
|
|
'values' => array(
|
|
array(
|
|
'id' => 'webp_auto_generator_enable_on',
|
|
'value' => 1,
|
|
'label' => $this->l('Yes', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 'webp_auto_generator_enable_off',
|
|
'value' => 0,
|
|
'label' => $this->l('No', $translations_name),
|
|
),
|
|
),
|
|
'default' => 1
|
|
),
|
|
array(
|
|
'type' => 'select',
|
|
'label' => $this->l('Operation mode', $translations_name),
|
|
'name' => $this->options_prefix . 'OPERATION_MODE',
|
|
'validation' => 'isAnything',
|
|
'options' => array(
|
|
'query' => array(
|
|
array(
|
|
'id' => 1,
|
|
'name' => $this->l('Generates all missing WebP images the first time a page is loaded', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 2,
|
|
'name' => $this->l('Use only the generated images', $translations_name),
|
|
)
|
|
),
|
|
'id' => 'id',
|
|
'name' => 'name',
|
|
),
|
|
'default' => 1,
|
|
),
|
|
array(
|
|
'type' => 'checkbox',
|
|
'label' => $this->l('Items allowed to generate', $translations_name),
|
|
'name' => $this->options_prefix . 'ALLOWED_GENERATED_IMAGES[]',
|
|
'default' => array('products', 'categories', 'manufacturers', 'suppliers', 'stores', 'cms', 'modules', 'theme', 'logo', 'others'),
|
|
'required' => false,
|
|
'values' => array(
|
|
'query' => $this->x13helper->getImageTypes(),
|
|
'value_field' => 'val',
|
|
'id' => 'val',
|
|
'name' => 'name',
|
|
),
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueEqualTo,
|
|
array(
|
|
$this->options_prefix . 'OPERATION_MODE' => 2,
|
|
)
|
|
),
|
|
'callback' => 'saveAsJson',
|
|
),
|
|
array(
|
|
'type' => 'html',
|
|
'name' => 'generated_info',
|
|
'html_content' => '
|
|
<p class="alert alert-info">' . $this->l('We recommend that you generate the images for the first time using the following ', $translations_name) . '
|
|
<a href="#conversion-fieldset" class="scrollto"><b>'.$this->l('generating by AJAX', $translations_name).'</b></a>
|
|
</p>
|
|
',
|
|
'ignore' => true,
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueEqualTo,
|
|
array(
|
|
$this->options_prefix . 'OPERATION_MODE' => 2,
|
|
)
|
|
),
|
|
),
|
|
array(
|
|
'type' => 'html',
|
|
'name' => 'separator_compression_settings',
|
|
'html_content' => '<h4 style="font-size:18px;">' . $this->l('Compression settings', $translations_name) . '</h4>',
|
|
'ignore' => true,
|
|
),
|
|
array(
|
|
'type' => 'radio',
|
|
'label' => $this->l('WebP coversion type', $translations_name),
|
|
'name' => $this->options_prefix . 'CONVERSION_TYPE',
|
|
'default' => 'cwebp',
|
|
'values' => $this->getConversionTypes(),
|
|
'form_group_class' => 'conversion-types'
|
|
),
|
|
array(
|
|
'type' => 'text',
|
|
'label' => $this->l('EWW - api key', $translations_name),
|
|
'name' => $this->options_prefix . 'EWW_API_KEY',
|
|
'validate' => 'isAnything',
|
|
'default' => '',
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueEqualTo,
|
|
array(
|
|
$this->options_prefix . 'CONVERSION_TYPE' => 'ewww',
|
|
)
|
|
),
|
|
),
|
|
|
|
array(
|
|
'type' => 'text',
|
|
'label' => $this->l('WPC - api key', $translations_name),
|
|
'name' => $this->options_prefix . 'WPC_API_KEY',
|
|
'validate' => 'isAnything',
|
|
'default' => '',
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueEqualTo,
|
|
array(
|
|
$this->options_prefix . 'CONVERSION_TYPE' => 'wpc',
|
|
)
|
|
),
|
|
),
|
|
array(
|
|
'type' => 'text',
|
|
'label' => $this->l('WPC - secret', $translations_name),
|
|
'name' => $this->options_prefix . 'WPC_SECRET',
|
|
'validate' => 'isAnything',
|
|
'default' => '',
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueEqualTo,
|
|
array(
|
|
$this->options_prefix . 'CONVERSION_TYPE' => 'wpc',
|
|
)
|
|
),
|
|
),
|
|
array(
|
|
'type' => 'text',
|
|
'label' => $this->l('WPC - api url', $translations_name),
|
|
'name' => $this->options_prefix . 'WPC_API_URL',
|
|
'validate' => 'isAnything',
|
|
'default' => '',
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueEqualTo,
|
|
array(
|
|
$this->options_prefix . 'CONVERSION_TYPE' => 'wpc',
|
|
)
|
|
),
|
|
),
|
|
array(
|
|
'type' => 'radio',
|
|
'label' => $this->l('WPC - api version', $translations_name),
|
|
'name' => $this->options_prefix . 'WPC_API_VERSION',
|
|
'default' => 2,
|
|
'validate' => 'isInt',
|
|
'values' => array(
|
|
array(
|
|
'id' => 0,
|
|
'value' => 0,
|
|
'label' => 0
|
|
),
|
|
array(
|
|
'id' => 1,
|
|
'value' => 1,
|
|
'label' => 1
|
|
),
|
|
array(
|
|
'id' => 2,
|
|
'value' => 2,
|
|
'label' => 2
|
|
),
|
|
),
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueEqualTo,
|
|
array(
|
|
$this->options_prefix . 'CONVERSION_TYPE' => 'wpc',
|
|
)
|
|
)
|
|
),
|
|
array(
|
|
'type' => 'switch',
|
|
'label' => $this->l('WPC - crypt api key in transfer', $translations_name),
|
|
'name' => $this->options_prefix . 'WPC_CRYPT_API_KEY_IN_TRANSFER',
|
|
'values' => array(
|
|
array(
|
|
'id' => 'wpc_crypt_enable_on',
|
|
'value' => 1,
|
|
'label' => $this->l('Yes', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 'wpc_crypt_enable_off',
|
|
'value' => 0,
|
|
'label' => $this->l('No', $translations_name),
|
|
),
|
|
),
|
|
'default' => 0,
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueEqualTo,
|
|
array(
|
|
$this->options_prefix . 'CONVERSION_TYPE' => 'wpc',
|
|
)
|
|
)
|
|
),
|
|
array(
|
|
'type' => 'select',
|
|
'label' => $this->l('Encoding', $translations_name),
|
|
'name' => $this->options_prefix . 'ENCODING',
|
|
'validation' => 'isAnything',
|
|
'options' => array(
|
|
'query' => array(
|
|
array(
|
|
'val' => 'auto',
|
|
'name' => $this->l('Auto', $translations_name),
|
|
),
|
|
array(
|
|
'val' => 'lossless',
|
|
'name' => $this->l('Lossless', $translations_name),
|
|
),
|
|
array(
|
|
'val' => 'lossy',
|
|
'name' => $this->l('Lossy', $translations_name),
|
|
)
|
|
),
|
|
'id' => 'val',
|
|
'name' => 'name',
|
|
),
|
|
'default' => 'auto',
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueNotEqualTo,
|
|
array(
|
|
$this->options_prefix . 'CONVERSION_TYPE' => 'gd',
|
|
)
|
|
),
|
|
),
|
|
array(
|
|
'type' => 'rangeSlider',
|
|
'label' => $this->l('Image quality (%)', $translations_name),
|
|
'name' => $this->options_prefix . 'IMAGE_QUALITY',
|
|
'default' => 90,
|
|
'validate' => 'isInt',
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueNotEqualTo,
|
|
array(
|
|
$this->options_prefix . 'ENCODING' => 'lossless',
|
|
)
|
|
). ' force-shown-gd'
|
|
),
|
|
array(
|
|
'type' => 'switch',
|
|
'label' => $this->l('Auto limit', $translations_name),
|
|
'name' => $this->options_prefix . 'AUTO_LIMIT',
|
|
'values' => array(
|
|
array(
|
|
'id' => 'auto_limit_enable_on',
|
|
'value' => 1,
|
|
'label' => $this->l('Yes', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 'auto_limit_enable_off',
|
|
'value' => 0,
|
|
'label' => $this->l('No', $translations_name),
|
|
),
|
|
),
|
|
'default' => 1,
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueNotEqualTo,
|
|
array(
|
|
$this->options_prefix . 'ENCODING' => 'lossless',
|
|
)
|
|
),
|
|
),
|
|
array(
|
|
'type' => 'rangeSlider',
|
|
'label' => $this->l('Alpha quality (%)', $translations_name),
|
|
'name' => $this->options_prefix . 'ALPHA_QUALITY',
|
|
'default' => 85,
|
|
'validate' => 'isInt',
|
|
'desc' => $this->l('It doesn\'t support jpeg images', $translations_name),
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueNotEqualTo,
|
|
array(
|
|
$this->options_prefix . 'ENCODING' => 'lossless',
|
|
$this->options_prefix . 'CONVERSION_TYPE' => 'gd',
|
|
)
|
|
)
|
|
),
|
|
array(
|
|
'type' => 'rangeSlider',
|
|
'label' => $this->l('Near lossless', $translations_name),
|
|
'name' => $this->options_prefix . 'NEAR_LOSSLESS',
|
|
'default' => 60,
|
|
'validate' => 'isInt',
|
|
'desc' => $this->l('The level of near-lossless image preprocessing', $translations_name),
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueNotEqualTo,
|
|
array(
|
|
$this->options_prefix . 'ENCODING' => 'lossy',
|
|
$this->options_prefix . 'CONVERSION_TYPE' => 'gd',
|
|
)
|
|
)
|
|
),
|
|
array(
|
|
'type' => 'radio',
|
|
'label' => $this->l('Migrate meta data of selected products', $translations_name),
|
|
'name' => $this->options_prefix . 'METADATA',
|
|
'default' => 'none',
|
|
'values' => array(
|
|
array(
|
|
'id' => 1,
|
|
'value' => 'none',
|
|
'label' => $this->l('None', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 2,
|
|
'value' => 'all',
|
|
'label' => $this->l('All', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 3,
|
|
'value' => 'exif',
|
|
'label' => $this->l('EXIF', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 4,
|
|
'value' => 'icc',
|
|
'label' => $this->l('ICC', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 5,
|
|
'value' => 'xmp',
|
|
'label' => $this->l('XMP', $translations_name),
|
|
),
|
|
),
|
|
'desc' => $this->l('The option depends on the selected type of photo conversion. The cwebp library works with any of the options, GD does not transfer any data, the other libraries can transfer the selected data', $translations_name),
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueNotEqualTo,
|
|
array(
|
|
$this->options_prefix . 'CONVERSION_TYPE' => 'gd',
|
|
)
|
|
),
|
|
),
|
|
array(
|
|
'type' => 'radio',
|
|
'label' => $this->l('Method', $translations_name),
|
|
'name' => $this->options_prefix . 'METHOD',
|
|
'default' => 6,
|
|
'values' => array(
|
|
array(
|
|
'id' => 0,
|
|
'value' => 0,
|
|
'label' => $this->l('0 (top performance)', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 1,
|
|
'value' => 1,
|
|
'label' => $this->l('1 (good performance)', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 2,
|
|
'value' => 2,
|
|
'label' => $this->l('2 (decent performance with better quality)', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 3,
|
|
'value' => 3,
|
|
'label' => $this->l('3 (quality equal to performance)', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 4,
|
|
'value' => 4,
|
|
'label' => $this->l('4 (decent quality with better performance)', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 5,
|
|
'value' => 5,
|
|
'label' => $this->l('5 (good quality)', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 6,
|
|
'value' => 6,
|
|
'label' => $this->l('6 (top quality)', $translations_name),
|
|
),
|
|
),
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueNotEqualTo,
|
|
array(
|
|
$this->options_prefix . 'CONVERSION_TYPE' => 'gd',
|
|
)
|
|
),
|
|
),
|
|
array(
|
|
'type' => 'switch',
|
|
'label' => $this->l('Sharp YUV', $translations_name),
|
|
'name' => $this->options_prefix . 'SHARP_YUV',
|
|
'values' => array(
|
|
array(
|
|
'id' => 'sharp_yuv_enable_on',
|
|
'value' => 1,
|
|
'label' => $this->l('Yes', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 'sharp_yuv_enable_off',
|
|
'value' => 0,
|
|
'label' => $this->l('No', $translations_name),
|
|
),
|
|
),
|
|
'default' => 1,
|
|
'desc' => $this->l('Use more accurate and sharper RGB->YUV conversion if needed. Note that this process is slower than the default \'fast\' RGB->YUV conversion.', $translations_name).'<br/>'.
|
|
'https://www.ctrl.blog/entry/webp-sharp-yuv.html',
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueNotEqualTo,
|
|
array(
|
|
$this->options_prefix . 'CONVERSION_TYPE' => 'gd',
|
|
)
|
|
)
|
|
),
|
|
array(
|
|
'type' => 'switch',
|
|
'label' => $this->l('Auto filter', $translations_name),
|
|
'name' => $this->options_prefix . 'AUTO_FILTER',
|
|
'values' => array(
|
|
array(
|
|
'id' => 'auto_filter_enable_on',
|
|
'value' => 1,
|
|
'label' => $this->l('Yes', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 'auto_filter_enable_off',
|
|
'value' => 0,
|
|
'label' => $this->l('No', $translations_name),
|
|
),
|
|
),
|
|
'default' => 0,
|
|
'desc' => $this->l('This algorithm will spend additional time optimizing the filtering strength to reach a well-balanced quality.', $translations_name)
|
|
),
|
|
array(
|
|
'type' => 'switch',
|
|
'label' => $this->l('Low memory', $translations_name),
|
|
'name' => $this->options_prefix . 'LOW_MEMORY',
|
|
'values' => array(
|
|
array(
|
|
'id' => 'low_memory_enable_on',
|
|
'value' => 1,
|
|
'label' => $this->l('Yes', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 'low_memory_enable_off',
|
|
'value' => 0,
|
|
'label' => $this->l('No', $translations_name),
|
|
),
|
|
),
|
|
'default' => 0,
|
|
'desc' => $this->l('Reduce memory usage of lossy encoding by saving four times the compressed size (typically). This will make the encoding slower and the output slightly different in size and distortion.', $translations_name),
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueNotEqualTo,
|
|
array(
|
|
$this->options_prefix . 'CONVERSION_TYPE' => 'gd',
|
|
)
|
|
),
|
|
),
|
|
array(
|
|
'type' => 'text',
|
|
'label' => $this->l('Command', $translations_name),
|
|
'name' => $this->options_prefix . 'COMMAND',
|
|
'validate' => 'isAnything',
|
|
'default' => '',
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueEqualTo,
|
|
array(
|
|
$this->options_prefix . 'CONVERSION_TYPE' => 'cwebp',
|
|
)
|
|
),
|
|
'desc' => $this->l('You can add additional parameters when using the command line for the cwebp library.', $translations_name),
|
|
),
|
|
array(
|
|
'type' => 'switch',
|
|
'label' => $this->l('Try common system paths', $translations_name),
|
|
'name' => $this->options_prefix . 'TRY_COMMON_SYSTEM_PATHS',
|
|
'values' => array(
|
|
array(
|
|
'id' => 'tcsp_enable_on',
|
|
'value' => 1,
|
|
'label' => $this->l('Yes', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 'tcsp_enable_off',
|
|
'value' => 0,
|
|
'label' => $this->l('No', $translations_name),
|
|
),
|
|
),
|
|
'default' => 0,
|
|
'desc' => $this->l('If the cwebP library is available on the server, but you have an error generating the pictures. The module will try to substitute the most popular paths to the library.', $translations_name),
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueEqualTo,
|
|
array(
|
|
$this->options_prefix . 'CONVERSION_TYPE' => 'cwebp',
|
|
)
|
|
),
|
|
),
|
|
array(
|
|
'type' => 'switch',
|
|
'label' => $this->l('Generate picture with nice (for cron jobs)', $translations_name),
|
|
'name' => $this->options_prefix . 'USE_NICE',
|
|
'values' => array(
|
|
array(
|
|
'id' => 'use_nice_enable_on',
|
|
'value' => 1,
|
|
'label' => $this->l('Yes', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 'use_nice_enable_off',
|
|
'value' => 0,
|
|
'label' => $this->l('No', $translations_name),
|
|
),
|
|
),
|
|
'default' => 0,
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueEqualTo,
|
|
array(
|
|
$this->options_prefix . 'CONVERSION_TYPE' => 'cwebp',
|
|
$this->options_prefix . 'CONVERSION_TYPE' => 'graphicsmagick',
|
|
$this->options_prefix . 'CONVERSION_TYPE' => 'imagemagick',
|
|
)
|
|
),
|
|
),
|
|
array(
|
|
'type' => 'html',
|
|
'name' => 'separator_test_compression',
|
|
'html_content' => '<h4 style="font-size:18px;">' . $this->l('Test compression', $translations_name) . '</h4>',
|
|
'ignore' => true,
|
|
),
|
|
array(
|
|
'type' => 'converTest',
|
|
'name' => 'webpConverterTest',
|
|
'label' => '',
|
|
'template' => 'module:'.$this->name.'/views/templates/admin/conversion_test.tpl',
|
|
'vars' => array(
|
|
'search_products_url' => $search_products_url,
|
|
'convert_image_url' => $convert_image_url,
|
|
'product_image_url' => $product_image_url,
|
|
'options_prefix' => $this->options_prefix
|
|
),
|
|
'ignore' => true,
|
|
),
|
|
array(
|
|
'type' => 'html',
|
|
'name' => 'separator_troubleshooting',
|
|
'html_content' => '<h4 style="font-size:18px;">' . $this->l('Troubleshooting', $translations_name) . '</h4>',
|
|
'ignore' => true,
|
|
),
|
|
array(
|
|
'type' => 'switch',
|
|
'label' => $this->l('Handle WebP support detection in the browser', $translations_name),
|
|
'name' => $this->options_prefix . 'BROWSER_SUPPORT',
|
|
'values' => array(
|
|
array(
|
|
'id' => 'browser_support_enable_on',
|
|
'value' => 1,
|
|
'label' => $this->l('Yes', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 'browser_support_enable_off',
|
|
'value' => 0,
|
|
'label' => $this->l('No', $translations_name),
|
|
),
|
|
),
|
|
'default' => 1,
|
|
'desc' => $this->l('New browsers will display files in the WebP format, and old browsers, such as Internet Explorer, will receive the image in JPG format', $translations_name),
|
|
),
|
|
array(
|
|
'type' => 'switch',
|
|
'label' => $this->l('Force WebP as', $translations_name) . ' <picture> ' . $this->l('tag', $translations_name),
|
|
'name' => $this->options_prefix . 'FORCE_WEBP_PICTURE',
|
|
'values' => array(
|
|
array(
|
|
'id' => 'force_webp_picture_enable_on',
|
|
'value' => 1,
|
|
'label' => $this->l('Yes', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 'force_webp_picture_enable_off',
|
|
'value' => 0,
|
|
'label' => $this->l('No', $translations_name),
|
|
),
|
|
),
|
|
'default' => 0,
|
|
'desc' => $this->l('Suggested solution only for external modules and error CloudFlare', $translations_name) . '<br/>' .
|
|
'<picture> <source srcset="img.webp" type="image/webp"> <img src="img.png" alt="" > </picture>',
|
|
),
|
|
array(
|
|
'type' => 'switch',
|
|
'label' => $this->l('Force .webp extension', $translations_name),
|
|
'name' => $this->options_prefix . 'FORCE_WEBP',
|
|
'values' => array(
|
|
array(
|
|
'id' => 'force_webp_enable_on',
|
|
'value' => 1,
|
|
'label' => $this->l('Yes', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 'force_webp_enable_off',
|
|
'value' => 0,
|
|
'label' => $this->l('No', $translations_name),
|
|
),
|
|
),
|
|
'default' => 0,
|
|
'desc' => $this->l('The generated photos will be displayed with the file extension as .webp instead of .jpg', $translations_name),
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueEqualTo,
|
|
array(
|
|
$this->options_prefix . 'FORCE_WEBP_PICTURE' => '0'
|
|
)
|
|
),
|
|
),
|
|
array(
|
|
'type' => 'html',
|
|
'name' => 'separator_cron_jobs',
|
|
'html_content' => '<h4 style="font-size:18px;">' . $this->l('CRON jobs', $translations_name) . '</h4>',
|
|
'ignore' => true,
|
|
),
|
|
array(
|
|
'type' => 'select',
|
|
'label' => $this->l('CRON operation mode', $translations_name),
|
|
'name' => $this->options_prefix . 'CRON_OPERATION_MODE',
|
|
'validation' => 'isAnything',
|
|
'options' => array(
|
|
'query' => array(
|
|
array(
|
|
'id' => 1,
|
|
'name' => $this->l('Generate only missing WebP images', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 2,
|
|
'name' => $this->l('Re-generate all WebP images', $translations_name),
|
|
)
|
|
),
|
|
'id' => 'id',
|
|
'name' => 'name',
|
|
),
|
|
'default' => 1,
|
|
),
|
|
array(
|
|
'type' => 'readonly',
|
|
'label' => $this->l('Url to CRON jobs', $translations_name),
|
|
'name' => $this->options_prefix . 'CRON_URL',
|
|
'readonly' => true,
|
|
'default' => Context::getContext()->shop->getBaseURL(true) . 'modules/'.$this->name.'/cron.php?token='.$this->x13helper->getCronToken(),
|
|
'ignore' => true,
|
|
'desc' => $this->l('Last run date:', $translations_name).' '.Configuration::get($this->options_prefix . 'CRON_DATE', null, null, null, '--')
|
|
)
|
|
),
|
|
'submit' => array(
|
|
'title' => static::getTranslationByKey('Save'),
|
|
),
|
|
),
|
|
);
|
|
if(Module::isInstalled('x13import')){
|
|
$key = array_search($this->options_prefix . 'WEBP_AUTO_GENERATOR_ENABLE', array_column($fields_form[0]['form']['input'], 'name'));
|
|
array_splice($fields_form[0]['form']['input'], $key + 1, 0, array(array(
|
|
'type' => 'switch',
|
|
'label' => $this->l('Skip WebP image generation during import product XML/CSV', $translations_name),
|
|
'name' => $this->options_prefix . 'IMPORT_SKIP',
|
|
'values' => array(
|
|
array(
|
|
'id' => 'IMPORT_SKIP_enable_on',
|
|
'value' => 1,
|
|
'label' => $this->l('Yes', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 'IMPORT_SKIP_enable_off',
|
|
'value' => 0,
|
|
'label' => $this->l('No', $translations_name),
|
|
),
|
|
),
|
|
'default' => 0,
|
|
'desc' => $this->l('Generally, generating WebP files will make the import of products take longer. You can turn off photo generation when importing products, and the photos themselves will be generated on the fly.', $translations_name),
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueEqualTo,
|
|
array(
|
|
$this->options_prefix . 'WEBP_AUTO_GENERATOR_ENABLE' => '1',
|
|
)
|
|
),
|
|
)));
|
|
}
|
|
if(Module::isInstalled('x13lazyload')){
|
|
$key = array_search($this->options_prefix . 'FORCE_WEBP_PICTURE', array_column($fields_form[0]['form']['input'], 'name'));
|
|
array_splice($fields_form[0]['form']['input'], $key + 1, 0, array(array(
|
|
'type' => 'switch',
|
|
'label' => $this->l('Enable support for LazyLoad module', $translations_name),
|
|
'name' => $this->options_prefix . 'FIX_LAZYLOAD_MODULE',
|
|
'values' => array(
|
|
array(
|
|
'id' => 'FIX_LAZYLOAD_MODULE_enable_on',
|
|
'value' => 1,
|
|
'label' => $this->l('Yes', $translations_name),
|
|
),
|
|
array(
|
|
'id' => 'FIX_LAZYLOAD_MODULE_enable_off',
|
|
'value' => 0,
|
|
'label' => $this->l('No', $translations_name),
|
|
),
|
|
),
|
|
'default' => 1,
|
|
'form_group_class' => $this->fieldDependsOn(
|
|
$this->dependsOnValueEqualTo,
|
|
array(
|
|
$this->options_prefix . 'FORCE_WEBP_PICTURE' => '1',
|
|
)
|
|
),
|
|
)));
|
|
}
|
|
return $fields_form;
|