本文整理汇总了PHP中kernel::get_host_mirror_img方法的典型用法代码示例。如果您正苦于以下问题:PHP kernel::get_host_mirror_img方法的具体用法?PHP kernel::get_host_mirror_img怎么用?PHP kernel::get_host_mirror_img使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kernel
的用法示例。
在下文中一共展示了kernel::get_host_mirror_img方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* 存储图片接口
*
* @param object $fileObject 继承SplFileInfo封装的类
* @param string $from 上传图片用户类型
*/
public function store($fileObject, $from, $imageType, $test = false)
{
$fileObject = $this->__preFileObject($fileObject);
$this->__checkImage($fileObject);
$file = $fileObject->getRealPath();
$imageParams = $this->__getImageParams($file);
$params['width'] = $imageParams['width'];
$params['height'] = $imageParams['height'];
$params['size'] = $fileObject->getClientSize();
$params['image_name'] = $fileObject->getClientOriginalName();
$params['img_type'] = $imageType;
$params['last_modified'] = time();
$storager = kernel::single('base_storager');
$result = $storager->upload($fileObject);
list($url, $ident, $storage) = explode('|', $result);
$params['url'] = kernel::get_host_mirror_img() . $url;
$params['ident'] = $ident;
$params['storage'] = $storage;
$accountData = $this->__imageAttach($from, $test);
$params['target_id'] = $accountData['target_id'];
$params['target_type'] = $accountData['target_type'];
$params['disabled'] = 0;
if ($row = $this->objMdlImage->getRow('id', ['url' => $params['url'], 'target_id' => $params['target_id'], ['target_type' => $params['target_type']]])) {
$this->objMdlImage->update($params, ['id' => $row['id']]);
} else {
$this->objMdlImage->insert($params);
}
unlink($file);
return $params;
}
示例2: store
public function store($params)
{
$text = $params['text'];
$size = $params['size'] ? $params['size'] : 300;
$qrCode = new QrCode();
$qrCodeContent = $qrCode->setText($text)->setSize(300)->setPadding(10)->setErrorCorrection('high')->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0))->setBackgroundColor(array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0))->setLabelFontSize(16)->getDataUri('png');
$tmpTarget = tempnam(TMP_DIR, 'qrCode');
file_put_contents($tmpTarget, $qrCodeContent);
$imageParams = getimagesize($tmpTarget);
$size = filesize($tmpTarget);
$imageName = $params['name'] . '.png';
$fileObject = new UploadedFile($tmpTarget, $imageName, $imageParams['mime'], $size, 0, true);
$storager = kernel::single('base_storager');
$result = $storager->upload($fileObject);
list($url, $ident, $storage) = explode('|', $result);
$insertData['url'] = kernel::get_host_mirror_img() . $url;
$insertData['ident'] = $ident;
$insertData['storage'] = $storage;
$insertData['width'] = $imageParams['width'];
$insertData['height'] = $imageParams['height'];
$insertData['size'] = $size;
$insertData['image_name'] = $imageName;
$insertData['img_type'] = 'qrcode';
$insertData['last_modified'] = time();
$insertData['target_id'] = '0';
$insertData['target_type'] = 'admin';
$insertData['disabled'] = 0;
$this->objMdlImage = app::get('image')->model('images');
if ($row = $this->objMdlImage->getRow('id', ['url' => $insertData['url'], 'target_id' => $insertData['target_id'], ['target_type' => $insertData['target_type']]])) {
$this->objMdlImage->update($insertData, ['id' => $row['id']]);
} else {
$this->objMdlImage->insert($insertData);
}
unlink($file);
return $insertData['url'];
}
示例3: preImageIdToUrl
/**
* 升级历史数据,将image_id转为URL存储
*/
private function preImageIdToUrl($imageId)
{
if (empty($imageId)) {
return false;
}
if ($imageId && strpos($imageId, '://')) {
return $imageId;
}
$imageIds = explode(',', $imageId);
$imageMdl = app::get('image')->model('image');
$data = $imageMdl->getList('*', ['image_id' => $imageIds]);
foreach ((array) $data as $row) {
if ($row['url'] && strpos($row['url'], '://')) {
$url[] = $row['url'];
} else {
$resource_host_url = kernel::get_host_mirror_img();
$url[] = $resource_host_url . str_replace(PUBLIC_DIR, '', MEDIA_DIR) . '/' . $row['ident'];
}
}
return implode(',', $url);
}