0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Added media file handling to the frontend

refs https://github.com/TryGhost/Toolbox/issues/95

- Media files uploaded through the Admin Media API should be accessible throught the frontend under `/content/media/`
- Note the feature is behind an alpha "mediaAPI" flag that has to be enabled in the labs first
This commit is contained in:
Naz 2021-11-04 21:22:06 +04:00
parent 142eff22ee
commit 6435dec938
2 changed files with 5 additions and 0 deletions

1
.gitignore vendored
View file

@ -104,6 +104,7 @@ projectFilesBackup
/content/apps/**/*
/content/themes/**/*
/content/images/**/*
/content/media/**/*
/content/adapters/storage/**/*
/content/adapters/scheduling/**/*
!/content/themes/casper

View file

@ -21,8 +21,10 @@ const customRedirects = require('../../server/services/redirects');
const siteRoutes = require('./routes');
const shared = require('../../server/web/shared');
const mw = require('./middleware');
const labs = require('../../shared/labs');
const STATIC_IMAGE_URL_PREFIX = `/${urlUtils.STATIC_IMAGE_URL_PREFIX}`;
const STATIC_MEDIA_URL_PREFIX = `/${constants.STATIC_MEDIA_URL_PREFIX}`;
let router;
@ -109,6 +111,8 @@ module.exports = function setupSiteApp(options = {}) {
// Serve blog images using the storage adapter
siteApp.use(STATIC_IMAGE_URL_PREFIX, mw.handleImageSizes, storage.getStorage('images').serve());
// Serve blog media using the storage adapter
siteApp.use(STATIC_MEDIA_URL_PREFIX, labs.enabledMiddleware('mediaAPI'), storage.getStorage('media').serve());
// @TODO find this a better home
// We do this here, at the top level, because helpers require so much stuff.