本文整理匯總了PHP中Images::LoadByRowidSize方法的典型用法代碼示例。如果您正苦於以下問題:PHP Images::LoadByRowidSize方法的具體用法?PHP Images::LoadByRowidSize怎麽用?PHP Images::LoadByRowidSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Images
的用法示例。
在下文中一共展示了Images::LoadByRowidSize方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createThumb
/**
* Create thumbnail for image in specified size
* @param $objImage
* @param $intNewWidth
* @param $intNewHeight
* @param $intType
*/
protected function createThumb($objImage, $intNewWidth, $intNewHeight, $intType)
{
// Verify that the size doesn't already exist in the db (usually the original which
// we don't want to overwrite)
$objImageThumbnail = Images::LoadByRowidSize($objImage->id, $intType);
if (!is_null($objImageThumbnail)) {
return;
}
//Get our original file from Lightspeed
$strOriginalFile = $objImage->image_path;
$strTempThumbnail = Images::GetImageName($strOriginalFile, $intNewWidth, $intNewHeight, 'temp');
$strNewThumbnail = Images::GetImageName($strOriginalFile, $intNewWidth, $intNewHeight);
$strOriginalFileWithPath = Images::GetImagePath($strOriginalFile);
$strTempThumbnailWithPath = Images::GetImagePath($strTempThumbnail);
$strNewThumbnailWithPath = Images::GetImagePath($strNewThumbnail);
$image = Yii::app()->image->load($strOriginalFileWithPath);
$quality = _xls_get_conf('IMAGE_QUALITY', '75');
$sharpness = _xls_get_conf('IMAGE_SHARPEN', '20');
if ($sharpness != 0) {
$image->resize($intNewWidth, $intNewHeight)->quality($quality)->sharpen($sharpness);
} else {
$image->resize($intNewWidth, $intNewHeight)->quality($quality);
}
if (Images::IsWritablePath($strNewThumbnail)) {
if (_xls_get_conf('IMAGE_FORMAT', 'jpg') == 'jpg') {
$strSaveFunc = 'imagejpeg';
$strLoadFunc = "imagecreatefromjpeg";
} else {
$strSaveFunc = 'imagepng';
$strLoadFunc = "imagecreatefrompng";
}
$image->save($strNewThumbnailWithPath);
//just save normally with no special effects
//See if we have a thumbnail record in our Images table, create or update
$objThumbImage = Images::model()->findByAttributes(array('width' => $intNewWidth, 'height' => $intNewHeight, 'index' => $objImage->index, 'parent' => $objImage->id, 'product_id' => $objImage->product_id));
if (!$objThumbImage instanceof Images) {
$objThumbImage = new Images();
Images::model()->deleteAllByAttributes(array('width' => $intNewWidth, 'height' => $intNewHeight, 'parent' => $objImage->id));
//sanity check to prevent SQL UNIQUE errors
}
$objThumbImage->image_path = $strNewThumbnail;
$objThumbImage->width = $intNewWidth;
$objThumbImage->height = $intNewHeight;
$objThumbImage->parent = $objImage->id;
$objThumbImage->index = $objImage->index;
$objThumbImage->product_id = $objImage->product_id;
$objThumbImage->save();
} else {
Yii::log("Directory permissions error writing " . $strNewThumbnail, 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
}
}
示例2: 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";
}