'description'=>$this->l('JPEG images have a small file size and standard quality. PNG images have a larger file size, a higher quality and support transparency. Note that in all cases the image files will have the .jpg extension.').'
'choices'=>array('jpg'=>$this->l('Use JPEG.'),'png'=>$this->l('Use PNG only if the base image is in PNG format.'),'png_all'=>$this->l('Use PNG for all images.'))
),
'PS_JPEG_QUALITY'=>array(
'title'=>$this->l('JPEG compression'),
'hint'=>$this->l('Ranges from 0 (worst quality, smallest file) to 100 (best quality, biggest file).').' '.$this->l('Recommended: 90.'),
'validation'=>'isUnsignedId',
'required'=>true,
'cast'=>'intval',
'type'=>'text'
),
'PS_PNG_QUALITY'=>array(
'title'=>$this->l('PNG compression'),
'hint'=>$this->l('PNG compression is lossless: unlike JPG, you do not lose image quality with a high compression ratio. However, photographs will compress very badly.').' '.$this->l('Ranges from 0 (biggest file) to 9 (smallest file, slowest decompression).').' '.$this->l('Recommended: 7.'),
'validation'=>'isUnsignedId',
'required'=>true,
'cast'=>'intval',
'type'=>'text'
),
'PS_IMAGE_GENERATION_METHOD'=>array(
'title'=>$this->l('Generate images based on one side of the source image'),
'validation'=>'isUnsignedId',
'required'=>false,
'cast'=>'intval',
'type'=>'select',
'list'=>array(
array(
'id'=>'0',
'name'=>$this->l('Automatic (longest side)')
),
array(
'id'=>'1',
'name'=>$this->l('Width')
),
array(
'id'=>'2',
'name'=>$this->l('Height')
)
),
'identifier'=>'id',
'visibility'=>Shop::CONTEXT_ALL
),
'PS_PRODUCT_PICTURE_MAX_SIZE'=>array(
'title'=>$this->l('Maximum file size of product customization pictures'),
'hint'=>$this->l('The maximum file size of pictures that customers can upload to customize a product (in bytes).'),
'validation'=>'isUnsignedInt',
'required'=>true,
'cast'=>'intval',
'type'=>'text',
'suffix'=>$this->l('bytes'),
'visibility'=>Shop::CONTEXT_ALL
),
'PS_PRODUCT_PICTURE_WIDTH'=>array(
'title'=>$this->l('Product picture width'),
'hint'=>$this->l('Width of product customization pictures that customers can upload (in pixels).'),
'validation'=>'isUnsignedInt',
'required'=>true,
'cast'=>'intval',
'type'=>'text',
'width'=>'px',
'suffix'=>$this->l('pixels'),
'visibility'=>Shop::CONTEXT_ALL
),
'PS_PRODUCT_PICTURE_HEIGHT'=>array(
'title'=>$this->l('Product picture height'),
'hint'=>$this->l('Height of product customization pictures that customers can upload (in pixels).'),
'validation'=>'isUnsignedInt',
'required'=>true,
'cast'=>'intval',
'type'=>'text',
'height'=>'px',
'suffix'=>$this->l('pixels'),
'visibility'=>Shop::CONTEXT_ALL
),
'PS_HIGHT_DPI'=>array(
'type'=>'bool',
'title'=>$this->l('Generate high resolution images'),
'required'=>false,
'is_bool'=>true,
'hint'=>$this->l('This will generate an additional file for each image (thus doubling your total amount of images). Resolution of these images will be twice higher.'),
'desc'=>$this->l('Enable to optimize the display of your images on high pixel density screens.'),
'title'=>$this->l('Use the legacy image filesystem'),
'hint'=>$this->l('This should be set to yes unless you successfully moved images in "Images" page under the "Preferences" menu.'),
'validation'=>'isBool',
'cast'=>'intval',
'required'=>false,
'type'=>'bool',
'visibility'=>Shop::CONTEXT_ALL
);
}
$this->fields_form=array(
'legend'=>array(
'title'=>$this->l('Image type'),
'icon'=>'icon-picture'
),
'input'=>array(
array(
'type'=>'text',
'label'=>$this->l('Name for the image type'),
'name'=>'name',
'required'=>true,
'hint'=>$this->l('Letters, underscores and hyphens only (e.g. "small_custom", "cart_medium", "large", "thickbox_extra-large").')
),
array(
'type'=>'text',
'label'=>$this->l('Width'),
'name'=>'width',
'required'=>true,
'maxlength'=>5,
'suffix'=>$this->l('pixels'),
'hint'=>$this->l('Maximum image width in pixels.')
),
array(
'type'=>'text',
'label'=>$this->l('Height'),
'name'=>'height',
'required'=>true,
'maxlength'=>5,
'suffix'=>$this->l('pixels'),
'hint'=>$this->l('Maximum image height in pixels.')
),
array(
'type'=>'switch',
'label'=>$this->l('Products'),
'name'=>'products',
'required'=>false,
'is_bool'=>true,
'hint'=>$this->l('This type will be used for Product images.'),
'values'=>array(
array(
'id'=>'products_on',
'value'=>1,
'label'=>$this->l('Enabled')
),
array(
'id'=>'products_off',
'value'=>0,
'label'=>$this->l('Disabled')
),
)
),
array(
'type'=>'switch',
'label'=>$this->l('Categories'),
'name'=>'categories',
'required'=>false,
'class'=>'t',
'is_bool'=>true,
'hint'=>$this->l('This type will be used for Category images.'),
'values'=>array(
array(
'id'=>'categories_on',
'value'=>1,
'label'=>$this->l('Enabled')
),
array(
'id'=>'categories_off',
'value'=>0,
'label'=>$this->l('Disabled')
),
)
),
array(
'type'=>'switch',
'label'=>$this->l('Manufacturers'),
'name'=>'manufacturers',
'required'=>false,
'is_bool'=>true,
'hint'=>$this->l('This type will be used for Manufacturer images.'),
'values'=>array(
array(
'id'=>'manufacturers_on',
'value'=>1,
'label'=>$this->l('Enabled')
),
array(
'id'=>'manufacturers_off',
'value'=>0,
'label'=>$this->l('Disabled')
),
)
),
array(
'type'=>'switch',
'label'=>$this->l('Suppliers'),
'name'=>'suppliers',
'required'=>false,
'is_bool'=>true,
'hint'=>$this->l('This type will be used for Supplier images.'),
'values'=>array(
array(
'id'=>'suppliers_on',
'value'=>1,
'label'=>$this->l('Enabled')
),
array(
'id'=>'suppliers_off',
'value'=>0,
'label'=>$this->l('Disabled')
),
)
),
array(
'type'=>'switch',
'label'=>$this->l('Scenes'),
'name'=>'scenes',
'required'=>false,
'class'=>'t',
'is_bool'=>true,
'hint'=>$this->l('This type will be used for Scene images.'),
'values'=>array(
array(
'id'=>'scenes_on',
'value'=>1,
'label'=>$this->l('Enabled')
),
array(
'id'=>'scenes_off',
'value'=>0,
'label'=>$this->l('Disabled')
),
)
),
array(
'type'=>'switch',
'label'=>$this->l('Stores'),
'name'=>'stores',
'required'=>false,
'is_bool'=>true,
'hint'=>$this->l('This type will be used for Store images.'),
'values'=>array(
array(
'id'=>'stores_on',
'value'=>1,
'label'=>$this->l('Enabled')
),
array(
'id'=>'stores_off',
'value'=>0,
'label'=>$this->l('Disabled')
),
)
),
),
'submit'=>array(
'title'=>$this->l('Save')
)
);
parent::__construct();
}
publicfunctionpostProcess()
{
// When moving images, if duplicate images were found they are moved to a folder named duplicates/
if(file_exists(_PS_PROD_IMG_DIR_.'duplicates/')){
$this->warnings[]=sprintf($this->l('Duplicate images were found when moving the product images. This is likely caused by unused demonstration images. Please make sure that the folder %s only contains demonstration images, and then delete it.'),_PS_PROD_IMG_DIR_.'duplicates/');
$this->errors[]=sprintf(Tools::displayError('Failed to resize image file to high resolution (%s)'),$dir.$image);
}
}
}
}
if(time()-$this->start_time>$this->max_execution_time-4){// stop 4 seconds before the timeout, just enough time to process the end of the page on a slow server
$this->errors[]=sprintf(Tools::displayError('Original image is corrupt (%s) for product ID %2$d or bad permission on folder'),$existing_img,(int)$imageObj->id_product);
$this->errors[]=sprintf(Tools::displayError('Original image is corrupt (%s) for product ID %2$d or bad permission on folder'),$existing_img,(int)$imageObj->id_product);
}
}
}
}
}else{
$this->errors[]=sprintf(Tools::displayError('Original image is missing or empty (%1$s) for product ID %2$d'),$existing_img,(int)$imageObj->id_product);
}
if(time()-$this->start_time>$this->max_execution_time-4){// stop 4 seconds before the tiemout, just enough time to process the end of the page on a slow server
if(time()-$this->start_time>$this->max_execution_time-4){// stop 4 seconds before the tiemout, just enough time to process the end of the page on a slow server
$this->errors[]=sprintf(Tools::displayError('Cannot write images for this type: %s. Please check the %s folder\'s writing permissions.'),$proc['type'],$proc['dir']);
}
}elseif($return=='timeout'){
$this->errors[]=Tools::displayError('Only part of the images have been regenerated. The server timed out before finishing.');
$this->errors[]=sprintf(Tools::displayError('Cannot write "No picture" image to (%s) images folder. Please check the folder\'s writing permissions.'),$proc['type']);
$this->errors[]=Tools::displayError('Not all images have been moved. The server timed out before finishing. Click on "Move images" again to resume the moving process.');
}elseif($result===false){
$this->errors[]=Tools::displayError('Error: Some -- or all -- images cannot be moved.');