...
|
...
|
@@ -37,7 +37,6 @@ class Images |
|
|
*/
|
|
|
static function template($fileName, $bucket = 'yhfair', $mode = 1)
|
|
|
{
|
|
|
|
|
|
return self::url($fileName, $bucket, $mode);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -65,26 +64,12 @@ class Images |
|
|
* @param string $bucket
|
|
|
* @return mixed
|
|
|
*/
|
|
|
public static function getImageUrl($fileName, $width, $height, $mode = 1, $bucket = 'yhfair'){
|
|
|
public static function getImageUrl($fileName, $width, $height, $mode = 1, $bucket = 'goodsimg')
|
|
|
{
|
|
|
if(!preg_match('|http://|', $fileName)){
|
|
|
$fileName = self::template($fileName, $bucket, $mode);
|
|
|
}
|
|
|
return str_replace('{width}', $width, str_replace('{height}', $height, str_replace('{mode}', $mode, $fileName)));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 缩略图模板
|
|
|
* @param $fileName
|
|
|
* @param $bucket
|
|
|
* @param string $position ()
|
|
|
* @param string $background
|
|
|
* @return string
|
|
|
*/
|
|
|
static function template2($fileName, $bucket, $position = 'center', $background = 'd2hpdGU=')
|
|
|
{
|
|
|
$domain = self::getDomain($bucket, $fileName);
|
|
|
$key = $bucket . $fileName;
|
|
|
return self::MakeBaseUrl($domain, $key) . '?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/' . $background . '/position/' . $position.'/quality/90';
|
|
|
return strtr($fileName, array('{width}' => $width, '{height}' => $height, '{mode}' => $mode));
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -140,34 +125,17 @@ class Images |
|
|
return "http://$domain/$keyEsc";
|
|
|
}
|
|
|
|
|
|
private static function MakeTemplateRequest($url)
|
|
|
{
|
|
|
private static function MakeTemplateRequest($url)
|
|
|
{
|
|
|
$ops = array();
|
|
|
$ops[] = '{mode}';
|
|
|
$ops[] = 'w/{width}';
|
|
|
$ops[] = 'h/{height}';
|
|
|
if (empty($ops)) {
|
|
|
return $url;
|
|
|
}
|
|
|
return $url . "?imageView/" . implode('/', $ops);
|
|
|
}
|
|
|
$ops[] = '{mode}';
|
|
|
$ops[] = 'w/{width}';
|
|
|
$ops[] = 'h/{height}';
|
|
|
|
|
|
/**
|
|
|
* 获取老的图片地址
|
|
|
* @param $fileName
|
|
|
* @param $bucket
|
|
|
* @param $width
|
|
|
* @param $height
|
|
|
* @param string $position
|
|
|
* @param string $background
|
|
|
* @return mixed
|
|
|
*/
|
|
|
public static function getUrl($fileName,$width,$height,$bucket, $position = 'center', $background = 'd2hpdGU=')
|
|
|
{
|
|
|
if(empty($fileName)){
|
|
|
$fileName = self::$default_image;
|
|
|
if (empty($ops)) {
|
|
|
return $url;
|
|
|
}
|
|
|
$url = self::template2($fileName, $bucket, $position, $background);
|
|
|
return str_replace(array('{width}','{height}'),array($width,$height),$url);
|
|
|
|
|
|
return $url . "?imageView/" . implode('/', $ops);
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|