mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 11:25:17 +00:00
Add previewUrl field and impl in cloudinary
Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
This commit is contained in:
parent
8bac1b1835
commit
3889fb87dc
@ -1,8 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
const fse = require('fs-extra');
|
||||
const { join } = require('path');
|
||||
|
||||
/**
|
||||
* An asynchronous bootstrap function that runs before
|
||||
* your application gets started.
|
||||
@ -11,17 +8,4 @@ const { join } = require('path');
|
||||
* run jobs, or perform some special logic.
|
||||
*/
|
||||
|
||||
module.exports = async () => {
|
||||
await fse.ensureDir('./public/uploads/sub-folder');
|
||||
|
||||
// example of overriding the upload provider
|
||||
strapi.plugins.upload.provider.extend({
|
||||
async upload(file) {
|
||||
const filePath = `/uploads/sub-folder/${file.hash}${file.ext}`;
|
||||
|
||||
// write file in public/assets folder
|
||||
await fse.writeFile(join(strapi.config.public.path, filePath), file.buffer);
|
||||
file.url = filePath;
|
||||
},
|
||||
});
|
||||
};
|
||||
module.exports = () => {};
|
||||
|
||||
@ -57,6 +57,10 @@
|
||||
"configurable": false,
|
||||
"required": true
|
||||
},
|
||||
"previewUrl": {
|
||||
"type": "string",
|
||||
"configurable": false
|
||||
},
|
||||
"provider": {
|
||||
"type": "string",
|
||||
"configurable": false,
|
||||
|
||||
@ -21,6 +21,17 @@ module.exports = {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
if (image.resource_type === 'video') {
|
||||
file.previewUrl = cloudinary.url(`${image.public_id}.gif`, {
|
||||
video_sampling: 6,
|
||||
delay: 200,
|
||||
width: 250,
|
||||
crop: 'scale',
|
||||
resource_type: 'video',
|
||||
});
|
||||
}
|
||||
|
||||
file.url = image.secure_url;
|
||||
file.provider_metadata = {
|
||||
public_id: image.public_id,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user