S3 gallery
This commit is contained in:
@@ -1,16 +1,23 @@
|
||||
const mongoose = require('mongoose');
|
||||
const mongoosePaginate = require('mongoose-paginate-v2');
|
||||
const s3Storage = require('../plugins/s3Storage');
|
||||
|
||||
function galleryUrl(img, prefix) {
|
||||
if (!img) return null;
|
||||
if (img.startsWith('http://') || img.startsWith('https://')) return img;
|
||||
return s3Storage.getPublicUrl(`${prefix}/${img}`);
|
||||
}
|
||||
|
||||
function image(img) {
|
||||
if (img) return '/uploads/images/gallery/' + img
|
||||
return galleryUrl(img, 'uploads/images/gallery');
|
||||
}
|
||||
|
||||
function graphic(img) {
|
||||
if (img) return '/uploads/graphics/gallery/' + img
|
||||
return galleryUrl(img, 'uploads/graphics/gallery');
|
||||
}
|
||||
|
||||
function video(vdo) {
|
||||
if (vdo) return '/uploads/videos/gallery/' + vdo
|
||||
return galleryUrl(vdo, 'uploads/videos/gallery');
|
||||
}
|
||||
|
||||
const GallerySchema = mongoose.Schema({
|
||||
|
||||
Reference in New Issue
Block a user