本文整理匯總了PHP中Images::addImage方法的典型用法代碼示例。如果您正苦於以下問題:PHP Images::addImage方法的具體用法?PHP Images::addImage怎麽用?PHP Images::addImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Images
的用法示例。
在下文中一共展示了Images::addImage方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionConvert
public function actionConvert()
{
@set_time_limit(0);
@ini_set('max_execution_time', 0);
$sql = 'SELECT id, owner_id FROM {{apartment}} WHERE 1';
$res = Yii::app()->db->createCommand($sql)->queryAll();
$ids = CHtml::listData($res, 'id', 'owner_id');
$sql = 'SELECT pid, imgsOrder FROM {{galleries}} WHERE 1';
$res = Yii::app()->db->createCommand($sql)->queryAll();
if ($res) {
foreach ($res as $item) {
$images = unserialize($item['imgsOrder']);
if (!isset($ids[$item['pid']])) {
continue;
}
if ($images) {
$cnt = 0;
foreach ($images as $image => $name) {
$filePath = Yii::getPathOfAlias('webroot.uploads.apartments.' . $item['pid'] . '.pictures') . '/' . $image;
Images::addImage($filePath, $item['pid'], $cnt == 0, $ids[$item['pid']]);
$cnt++;
}
}
}
}
}
示例2: actionConvert
public function actionConvert()
{
@set_time_limit(0);
@ini_set('max_execution_time', 0);
@ini_set('gd.jpeg_ignore_warning', 1);
$limit = 200;
$data = Yii::app()->statePersister->load();
$lastImportId = isset($data['last_import_id']) ? $data['last_import_id'] : 0;
$sql = 'SELECT id, owner_id FROM {{apartment}} WHERE id > ' . $lastImportId . ' LIMIT ' . $limit;
$res = Yii::app()->db->createCommand($sql)->queryAll();
$ids = CHtml::listData($res, 'id', 'owner_id');
$sql = 'SELECT pid, imgsOrder FROM {{galleries}} WHERE pid > ' . $lastImportId . ' LIMIT ' . $limit;
$res = Yii::app()->db->createCommand($sql)->queryAll();
$i = 0;
if ($res) {
foreach ($res as $item) {
$images = unserialize($item['imgsOrder']);
if (!isset($ids[$item['pid']])) {
continue;
}
if ($images) {
$cnt = 0;
foreach ($images as $image => $name) {
$filePath = Yii::getPathOfAlias('webroot.uploads.apartments.' . $item['pid'] . '.pictures') . '/' . $image;
try {
Images::addImage($filePath, $item['pid'], $cnt == 0, $ids[$item['pid']]);
} catch (Exception $e) {
echo '<b>Выброшено исключение: ', $e->getMessage(), "\n</b><br>";
}
$cnt++;
}
}
$data['last_import_id'] = $item['pid'];
Yii::app()->statePersister->save($data);
$i++;
if ($i >= $limit) {
break;
}
}
}
echo 'Converted ' . $i . ' ads';
}