public function resize($path, $width, $height, $options = array(), $htmlAttributes = array(), $return = false) { $filename = basename($path); $uploadsDir = dirname(basename($path)); if ($uploadsDir === '.') { $uploadsDir = ''; } $cacheDir = dirname($path); $options = Hash::merge(array('aspect' => true, 'adapter' => false, 'cacheDir' => $cacheDir, 'uploadsDir' => $uploadsDir), $options); $adapter = $options['adapter']; if ($adapter === 'LegacyLocalAttachment') { $options['cacheDir'] = 'resized'; $options['resizedInd'] = '.resized-'; $options['uploadsDir'] = 'uploads'; } $result = parent::resize($path, $width, $height, $options, $htmlAttributes, $return); $data = compact('result', 'path', 'width', 'height', 'aspect', 'htmlAttributes', 'adapter'); Croogo::dispatchEvent('Assets.AssetsImageHelper.resize', $this->_View, $data); return $result; }
if (!$width && !$height) { unset($paths[4]); } return implode('/', $paths); } /* * Generate the image url corresponding to the dimension * Need to change the code when copy to another model * * @author Lam Huynh */ protected function generateImageUrl($width = null, $height = null) {
} return ''; } /** * @Author: ANH DUNG Sep 04, 2014 * @Todo: display account type of user * @Param: $role_id of user */ public static function getAccountType($role_id) { if (isset(Users::$ACCOUNT_TYPE[$role_id])) { return Users::$ACCOUNT_TYPE[$role_id];
public static function holderUrl($url, $width, $height) { if ($url) { return $url; } $noImgSrc = Yii::getPathOfAlias('webroot') . '/upload/noimage/noimage-all.jpg'; $noImg = Yii::getPathOfAlias('webroot') . "/upload/noimage/{$width}x{$height}.jpg"; $noImageUrl = Yii::app()->baseUrl . "/upload/noimage/{$width}x{$height}.jpg"; // resize the placeholder image file if (!is_file($noImg)) { ImageHelper::resize($noImgSrc, $noImg, $width, $height); } return $noImageUrl; }
public function getImageUrl($width = null, $height = null, $watermark = false) { $imgFile = $this->generateImagePath($width, $height, $watermark); if (!is_file($imgFile)) { // resize image $srcImg = $this->generateImagePath(); ImageHelper::resize($srcImg, $imgFile, $width, $height, array('fit' => false)); } $imgUrl = $this->generateImageUrl($width, $height, $watermark); return is_file($imgFile) ? $imgUrl : null; }