本文整理汇总了PHP中Images::GetImageUri方法的典型用法代码示例。如果您正苦于以下问题:PHP Images::GetImageUri方法的具体用法?PHP Images::GetImageUri怎么用?PHP Images::GetImageUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Images
的用法示例。
在下文中一共展示了Images::GetImageUri方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLocalLink
public static function getLocalLink($objImage, $intType = ImagesType::normal, $AbsoluteUrl = false)
{
list($intWidth, $intHeight) = ImagesType::GetSize($intType);
if (!is_null($objImage)) {
//See if image exists for chosen size
$objImageThumbnail = Images::LoadByRowidSize($objImage->id, $intType);
//If exists, return URL based on stored path
if ($objImageThumbnail && $objImageThumbnail->ImageFileExists()) {
return Images::GetImageUri($objImageThumbnail->image_path, $AbsoluteUrl);
}
//If we are to this point, we don't have the size of thumbnail we need, so can we create it on the fly
//from the parent image
$objParentImage = Images::LoadByParent($objImage->id);
if ($objParentImage && $objParentImage->ImageFileExists()) {
$objProduct = Product::model()->findByPk($objParentImage->product_id);
$strPath = $objParentImage->image_path;
if (!empty($strPath)) {
//We have a parent image
//Kick our thumbnail creation back to the processor
$blbImage = imagecreatefrompng(Images::GetImagePath($strPath));
$objEvent = new CEventPhoto('Images', 'onUploadPhoto', $blbImage, $objProduct, $objParentImage->index);
_xls_raise_events('CEventPhoto', $objEvent);
//At this point, the new size has been created, so look it up again just like above
//This time we should find it
//See if image exists for chosen size
$objImageThumbnail = Images::LoadByRowidSize($objImage->id, $intType);
//If exists, return URL based on stored path
if ($objImageThumbnail && $objImageThumbnail->ImageFileExists()) {
return Images::GetImageUri($objImageThumbnail->image_path, $AbsoluteUrl);
}
}
}
}
return "http://res.cloudinary.com/lightspeed-retail/image/upload/c_fit,h_" . $intHeight . ",w_" . $intWidth . "/v1389476545/no_product.png";
}
示例2: resizeImage
public static function resizeImage($imagePath, $intNewWidth, $intNewHeight)
{
if (strpos($imagePath, 'http') !== false) {
return $imagePath;
}
//Get our original file from LightSpeed
$strOriginalFile = $imagePath;
$strTempThumbnail = Images::GetImageName($strOriginalFile, $intNewWidth, $intNewHeight, 'temp');
$strNewThumbnail = Images::GetImageName($strOriginalFile, $intNewWidth, $intNewHeight);
if (file_exists(Images::GetImagePath($strNewThumbnail))) {
return Images::GetImageUri($strNewThumbnail, true);
}
$strOriginalFileWithPath = Images::GetImagePath($strOriginalFile);
$strTempThumbnailWithPath = Images::GetImagePath($strTempThumbnail);
$strNewThumbnailWithPath = Images::GetImagePath($strNewThumbnail);
$image = Yii::app()->image->load($strOriginalFileWithPath);
$image->resize($intNewWidth, $intNewHeight)->quality(_xls_get_conf('IMAGE_QUALITY', '75'))->sharpen(_xls_get_conf('IMAGE_SHARPEN', '20'));
if (Images::IsWritablePath($strNewThumbnail)) {
if (_xls_get_conf('IMAGE_FORMAT', 'jpg') == 'jpg') {
$strSaveFunc = 'imagejpeg';
$strLoadFunc = "imagecreatefromjpeg";
} else {
$strSaveFunc = 'imagepng';
$strLoadFunc = "imagecreatefrompng";
}
$image->save($strTempThumbnailWithPath, false);
try {
$src = $strLoadFunc($strTempThumbnailWithPath);
//We've saved the resize, so let's load it and resave it centered
$dst_file = $strNewThumbnailWithPath;
$dst = imagecreatetruecolor($intNewWidth, $intNewHeight);
$colorFill = imagecolorallocate($dst, 255, 255, 255);
imagefill($dst, 0, 0, $colorFill);
if (_xls_get_conf('IMAGE_FORMAT', 'jpg') == 'png') {
imagecolortransparent($dst, $colorFill);
}
$arrOrigSize = getimagesize($strOriginalFileWithPath);
$arrSize = Images::CalculateNewSize($arrOrigSize[0], $arrOrigSize[1], $intNewWidth, $intNewHeight);
$intStartX = $intNewWidth / 2 - $arrSize[0] / 2;
imagecopymerge($dst, $src, $intStartX, 0, 0, 0, $arrSize[0], $arrSize[1], 100);
$strSaveFunc($dst, $dst_file);
@unlink($strTempThumbnailWithPath);
} catch (Exceiption $e) {
}
return Images::GetImageUri($strNewThumbnail, true);
} else {
Yii::log("Directory permissions error attempting to save " . $strNewThumbnail, 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
return false;
}
}