|
@@ -37,7 +37,6 @@ class Images |
|
@@ -37,7 +37,6 @@ class Images |
37
|
*/
|
37
|
*/
|
38
|
static function template($fileName, $bucket = 'yhfair', $mode = 1)
|
38
|
static function template($fileName, $bucket = 'yhfair', $mode = 1)
|
39
|
{
|
39
|
{
|
40
|
-
|
|
|
41
|
return self::url($fileName, $bucket, $mode);
|
40
|
return self::url($fileName, $bucket, $mode);
|
42
|
}
|
41
|
}
|
43
|
|
42
|
|
|
@@ -65,26 +64,12 @@ class Images |
|
@@ -65,26 +64,12 @@ class Images |
65
|
* @param string $bucket
|
64
|
* @param string $bucket
|
66
|
* @return mixed
|
65
|
* @return mixed
|
67
|
*/
|
66
|
*/
|
68
|
- public static function getImageUrl($fileName, $width, $height, $mode = 1, $bucket = 'yhfair'){
|
67
|
+ public static function getImageUrl($fileName, $width, $height, $mode = 1, $bucket = 'goodsimg')
|
|
|
68
|
+ {
|
69
|
if(!preg_match('|http://|', $fileName)){
|
69
|
if(!preg_match('|http://|', $fileName)){
|
70
|
$fileName = self::template($fileName, $bucket, $mode);
|
70
|
$fileName = self::template($fileName, $bucket, $mode);
|
71
|
}
|
71
|
}
|
72
|
- return str_replace('{width}', $width, str_replace('{height}', $height, str_replace('{mode}', $mode, $fileName)));
|
|
|
73
|
- }
|
|
|
74
|
-
|
|
|
75
|
- /**
|
|
|
76
|
- * 缩略图模板
|
|
|
77
|
- * @param $fileName
|
|
|
78
|
- * @param $bucket
|
|
|
79
|
- * @param string $position ()
|
|
|
80
|
- * @param string $background
|
|
|
81
|
- * @return string
|
|
|
82
|
- */
|
|
|
83
|
- static function template2($fileName, $bucket, $position = 'center', $background = 'd2hpdGU=')
|
|
|
84
|
- {
|
|
|
85
|
- $domain = self::getDomain($bucket, $fileName);
|
|
|
86
|
- $key = $bucket . $fileName;
|
|
|
87
|
- return self::MakeBaseUrl($domain, $key) . '?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/' . $background . '/position/' . $position.'/quality/90';
|
72
|
+ return strtr($fileName, array('{width}' => $width, '{height}' => $height, '{mode}' => $mode));
|
88
|
}
|
73
|
}
|
89
|
|
74
|
|
90
|
/**
|
75
|
/**
|
|
@@ -140,34 +125,17 @@ class Images |
|
@@ -140,34 +125,17 @@ class Images |
140
|
return "http://$domain/$keyEsc";
|
125
|
return "http://$domain/$keyEsc";
|
141
|
}
|
126
|
}
|
142
|
|
127
|
|
143
|
- private static function MakeTemplateRequest($url)
|
|
|
144
|
- {
|
128
|
+ private static function MakeTemplateRequest($url)
|
|
|
129
|
+ {
|
145
|
$ops = array();
|
130
|
$ops = array();
|
146
|
- $ops[] = '{mode}';
|
|
|
147
|
- $ops[] = 'w/{width}';
|
|
|
148
|
- $ops[] = 'h/{height}';
|
|
|
149
|
- if (empty($ops)) {
|
|
|
150
|
- return $url;
|
|
|
151
|
- }
|
|
|
152
|
- return $url . "?imageView/" . implode('/', $ops);
|
|
|
153
|
- }
|
131
|
+ $ops[] = '{mode}';
|
|
|
132
|
+ $ops[] = 'w/{width}';
|
|
|
133
|
+ $ops[] = 'h/{height}';
|
154
|
|
134
|
|
155
|
- /**
|
|
|
156
|
- * 获取老的图片地址
|
|
|
157
|
- * @param $fileName
|
|
|
158
|
- * @param $bucket
|
|
|
159
|
- * @param $width
|
|
|
160
|
- * @param $height
|
|
|
161
|
- * @param string $position
|
|
|
162
|
- * @param string $background
|
|
|
163
|
- * @return mixed
|
|
|
164
|
- */
|
|
|
165
|
- public static function getUrl($fileName,$width,$height,$bucket, $position = 'center', $background = 'd2hpdGU=')
|
|
|
166
|
- {
|
|
|
167
|
- if(empty($fileName)){
|
|
|
168
|
- $fileName = self::$default_image;
|
135
|
+ if (empty($ops)) {
|
|
|
136
|
+ return $url;
|
169
|
}
|
137
|
}
|
170
|
- $url = self::template2($fileName, $bucket, $position, $background);
|
|
|
171
|
- return str_replace(array('{width}','{height}'),array($width,$height),$url);
|
138
|
+
|
|
|
139
|
+ return $url . "?imageView/" . implode('/', $ops);
|
172
|
}
|
140
|
}
|
173
|
} |
141
|
} |