...
|
...
|
@@ -3,8 +3,10 @@ |
|
|
var cdnDomains = require('../../../../config/dns-prefetch');
|
|
|
|
|
|
function cdnReplace(cdn, imgUrl) {
|
|
|
var key;
|
|
|
|
|
|
if (cdn === 'qcloud') {
|
|
|
for (var key in cdnDomains) {
|
|
|
for (key in cdnDomains) {
|
|
|
if (imgUrl.indexOf(key) >= 0) {
|
|
|
imgUrl = imgUrl.replace(key, cdnDomains[key]);
|
|
|
}
|
...
|
...
|
@@ -15,12 +17,13 @@ function cdnReplace(cdn, imgUrl) { |
|
|
|
|
|
module.exports = function(imageUrl, opts) {
|
|
|
var cdn = window.cdn;
|
|
|
var params, urls, query, uri;
|
|
|
|
|
|
if (imageUrl) {
|
|
|
var params = opts.hash;
|
|
|
var urls = imageUrl.split('?');
|
|
|
var query = urls[1] || '';
|
|
|
var uri = urls[0];
|
|
|
params = opts.hash;
|
|
|
urls = imageUrl.split('?');
|
|
|
query = urls[1] || '';
|
|
|
uri = urls[0];
|
|
|
|
|
|
if (uri.indexOf('http:') === 0) {
|
|
|
uri = uri.replace('http:', '');
|
...
|
...
|
@@ -29,7 +32,8 @@ module.exports = function(imageUrl, opts) { |
|
|
uri = cdnReplace(cdn, uri);
|
|
|
|
|
|
if (query) {
|
|
|
query = query.replace(/{width}/g, params.w).replace(/{height}/g, params.h).replace(/{mode}/g, (params.mode || 2));
|
|
|
query = query.replace(/{width}/g, params.w).replace(/{height}/g,
|
|
|
params.h).replace(/{mode}/g, (params.mode || 2));
|
|
|
|
|
|
if (query.indexOf('imageView2') === 0) {
|
|
|
if (params.q && query.indexOf('/q/') > 0) {
|
...
|
...
|
@@ -57,7 +61,7 @@ module.exports = function(imageUrl, opts) { |
|
|
} else {
|
|
|
query = 'imageView2/2/interlace/1/q/' + (params.q || 75);
|
|
|
}
|
|
|
return uri + '?' + query;
|
|
|
return uri + '?' + query + '&imageslim';
|
|
|
} else {
|
|
|
return imageUrl;
|
|
|
}
|
...
|
...
|
|