Updated image middleware to use new shared function

- we have a function for generating _o filenames in @tryghost/image-transform as of v0.2.0
- this  updates our Ghost code to use it
This commit is contained in:
Hannah Wolfe 2020-03-30 18:26:48 +01:00
parent 7f1d3ebc07
commit 7964c1de79

View File

@ -1,5 +1,4 @@
const cloneDeep = require('lodash/cloneDeep');
const path = require('path');
const config = require('../../../../config');
const {logging} = require('../../../../lib/common');
const imageTransform = require('@tryghost/image-transform');
@ -30,8 +29,7 @@ module.exports = function normalize(req, res, next) {
req.files.push(Object.assign(req.file, {path: out}));
// CASE: push original image, we keep a copy of it
const parsedFileName = path.parse(req.file.name);
const newName = `${parsedFileName.name}_o${parsedFileName.ext}`;
const newName = imageTransform.generateOriginalImageName(req.file.name);
req.files.push(Object.assign(cloneDeep(req.file), {path: originalPath, name: newName}));
next();