Images should be under the product id not permalink
parent
e6feac9e7a
commit
c9732ad235
|
@ -147,16 +147,16 @@ const getThemes = () => {
|
|||
return fs.readdirSync(path.join(__dirname, '../', 'views', 'themes')).filter(file => fs.statSync(path.join(path.join(__dirname, '../', 'views', 'themes'), file)).isDirectory());
|
||||
};
|
||||
|
||||
const getImages = async (dir, req, res, callback) => {
|
||||
const getImages = async (id, req, res, callback) => {
|
||||
const db = req.app.db;
|
||||
|
||||
const product = await db.products.findOne({ _id: getId(dir) });
|
||||
const product = await db.products.findOne({ _id: getId(id) });
|
||||
if(!product){
|
||||
return[];
|
||||
}
|
||||
|
||||
// loop files in /public/uploads/
|
||||
const files = await glob.sync(`public/uploads/${product.productPermalink}/**`, { nosort: true });
|
||||
const files = await glob.sync(`public/uploads/${product._id.toString()}/**`, { nosort: true });
|
||||
|
||||
// sort array
|
||||
files.sort();
|
||||
|
|
|
@ -409,7 +409,7 @@ router.post('/admin/file/upload', restrict, checkAccess, upload.single('upload_f
|
|||
return;
|
||||
}
|
||||
|
||||
const productPath = product.productPermalink;
|
||||
const productPath = product._id.toString();
|
||||
const uploadDir = path.join('public/uploads', productPath);
|
||||
|
||||
// Check directory and create (if needed)
|
||||
|
|
Loading…
Reference in New Issue