Fix display of small images

parent 2c73fbe4
Pipeline #228 passed with stages
'use strict';
var lwip;
var path = require('path');
try {lwip = require('lwip');}
......@@ -10,15 +11,15 @@ catch(e) {
module.exports = function(file, targetDir, width, height) {
if(lwip && (width || height)) {
var tmp = path.basename(file).split('.');
let tmp = path.basename(file).split('.');
tmp.splice(-1,1);
var base = tmp.join('.');
var targetFile = base+'_thumb_';
let base = tmp.join('.');
let targetFile = base+'_thumb_';
if(width) targetFile += width;
targetFile += 'x';
if(height) targetFile += height;
targetFile += '.png';
var ret = targetFile;
let ret = targetFile;
targetFile = path.resolve(targetDir,targetFile);
lwip.open(file, function(err, image) {
function doResize() {
......@@ -49,6 +50,6 @@ module.exports = function(file, targetDir, width, height) {
})
return ret;
} else {
return file;
return path.basename(file);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment