最模板 - 外贸网站建设,外贸网站模板

最模板

当前位置: 首页 > PrestaShop > PrestaShop教程 >

PrestaShop批量重新生成图片

时间:2014-06-21 12:32来源:未知 作者:最模板zuimoban 点击:
?php define(_PS_ADMIN_DIR_, getcwd()); define(PS_ADMIN_DIR, _PS_ADMIN_DIR_); // Retro-compatibility include(PS_ADMIN_DIR./../config/config.inc.php); include(PS_ADMIN_DIR./functions.php); @include(PS_ADMIN_DIR./toolbar.php); include(PS_ADMIN

<?php
define(‘_PS_ADMIN_DIR_’, getcwd());
define(‘PS_ADMIN_DIR’, _PS_ADMIN_DIR_); // Retro-compatibility

include(PS_ADMIN_DIR.’/../config/config.inc.php’);
include(PS_ADMIN_DIR.’/functions.php’);
@include(PS_ADMIN_DIR.’/toolbar.php’);
include(PS_ADMIN_DIR.’/header.inc.php’);

ob_implicit_flush(true);
@ini_set(‘display_errors’, ‘off’);
@set_time_limit(0);
@ini_set(‘max_execution_time’, 0);
@ini_set(‘memory_limit’, ’8000M’);

$images = Image::getAllImages();
$type = ImageType::getImagesTypes(‘products’);

echo ‘<pre>Step 1 OK~</pre>’;
ob_flush();

foreach ($images as $image){
$existing_img = ‘../img/p/’.chunk_split($image['id_image'], 1, ‘/’).$image['id_image'].’.jpg’;
if (file_exists($existing_img) && filesize($existing_img)){
foreach ($type as $imageType){
$newImg = str_replace(‘.jpg’, ‘-’.$imageType['name'].’.jpg’, $existing_img);
if(!file_exists($newImg)){
if (!imageResize($existing_img, $newImg, $imageType['width'], $imageType['height']))
{
file_put_contents(‘original_image_fail.log’, $existing_img.”\r\n”, FILE_APPEND);
}
}
}
}else{
file_put_contents(‘original_image_missing.log’, $existing_img.”\r\n”, FILE_APPEND);
}
}

echo ‘<h1>End! Total:’.count($images).’ OK~</h1>’;

include(PS_ADMIN_DIR.’/footer.inc.php’);
?>


(责任编辑:最模板)
------分隔线----------------------------
栏目列表
推荐内容