mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 05:37:34 +03:00
f27282bc3f
no issue - adds `populateImageSizes()` to our mobiledoc lib module - uses `image-size` lib to speed up reading of image dimensions - for local images, use storage adapter with same guards as used by `handle-image-sizes` middleware so that we don't insert srcsets for images that aren't transformable - for unsplash images, remove any width and crop params from the url so it points to the full-size image - use `populateImageSizes(mobiledoc)` to modify post model's mobiledoc when re-rendering
21 lines
753 B
JavaScript
21 lines
753 B
JavaScript
const UrlUtils = require('@tryghost/url-utils');
|
|
const config = require('./config');
|
|
|
|
const urlUtils = new UrlUtils({
|
|
url: config.get('url'),
|
|
adminUrl: config.get('admin:url'),
|
|
apiVersions: config.get('api:versions'),
|
|
defaultApiVersion: 'v3',
|
|
slugs: config.get('slugs').protected,
|
|
redirectCacheMaxAge: config.get('caching:301:maxAge'),
|
|
baseApiPath: '/ghost/api',
|
|
get cardTransformers() {
|
|
// do not require mobiledoc until it's requested to avoid circular dependencies
|
|
// shared/url-utils > server/lib/mobiledoc > server/lib/image/image-size > server/adapters/storage/utils
|
|
const mobiledoc = require('../server/lib/mobiledoc');
|
|
return mobiledoc.cards;
|
|
}
|
|
});
|
|
|
|
module.exports = urlUtils;
|