ImageKit's Ghost storage adapter.
- Up to date with the most recent Ghost release.
- Uses the latest ImageKit NodeJS SDK.
- Supports image read, existence check, and upload.
- Serve existing images present in Ghost's default storage.
- Ability to upload images into a specific directory.
- Ability to configure uploads in dated subdirectories like the default Ghost local storage adapter in
YYYY/MM
format. - Use ImageKit's upload API to set
tags
,useUniqueFileName
, andfolder
.
- Go into your Ghost project's root directory.
- Install the adapter:
yarn add ghost-imagekit-store
cp node_modules/ghost-imagekit-store/dist/src/index.js content/adapters/storage/imagekit/
- Configure Ghost's config file.
Here's an example of using this adapter with a containerized Ghost:
FROM ghost:5-alpine as imagekit
RUN apk add g++ make python3
RUN su-exec node yarn add ghost-imagekit-store
FROM ghost:5-alpine
COPY --chown=node:node --from=imagekit $GHOST_INSTALL/node_modules $GHOST_INSTALL/node_modules
COPY --chown=node:node --from=imagekit $GHOST_INSTALL/node_modules/ghost-imagekit-store/dist/src/index.js $GHOST_INSTALL/content/adapters/storage/imagekit/index.js
# Here, we use the Ghost CLI to set some pre-defined values.
RUN set -ex; \
su-exec node ghost config storage.active imagekit; \
su-exec node ghost config storage.imagekit.uploadOptions.useUniqueFileName true; \
su-exec node ghost config storage.imagekit.uploadOptions.folder /ghost/blog;
Make sure the content path is correctly set in the Ghost configuration:
"paths": {
"contentPath": "/var/lib/ghost/content/"
}
Ensure that the GHOST_CONTENT
environment variable is set to the same value as that of paths.contentPath
in your Ghost app.
Check out configuration.json.dist or below for a complete example.
{
"storage": {
"active": "imagekit",
"imagekit": {
"enableDatedFolders": true,
"auth": {
"privateKey": "your-private-key",
"publicKey": "your-public-key",
"urlEndpoint": "https://ik.imagekit.io/your-imagekit-id"
},
"uploadOptions": {
"useUniqueFileName": false,
"folder": "/sample",
"tags": ["blog"]
}
}
},
"imageOptimization": {
"resize": false
}
}
- Make sure Ghost Image Optimization is disabled.
- The optional
enableDatedFolders
setting allows uploading images into dated sub-directories (like the default Ghost Local Storage Adapter). It istrue
by default. - The
auth
property is used to configure your ImageKit account's credentials and URL endpoint. You can find them in the dashboard. - The
uploadOptions
property allows you to configure ImageKit's upload options. You can configureuseUniqueFileName
,folder
, andtags
.
uploadOptions.useUniqueFileName = true
Ghost's local storage adaptor handles duplicate file names automatically. When uploading a file to a location where a file with the same name already exists, ImageKit creates a new file version. In order to avoid this,useUniqueFileName
can be set totrue
.uploadOptions.tags = ["travel", "discover"]
if you want to add associations of tags to your uploaded images.uploadOptions.folder = "/ghost/blog"
allows to upload all your images into a specific directory in your ImageKit media library. By default, files are uploaded to the root of media library.
Ensure that Restrict unsigned image URLs
settings is turned off in your ImageKit account. This is because the storage adapter currently does not support fetching images that require signed URLs, including private files.
To install, run:
yarn install
To run tests and generate coverage, run:
yarn test
To build, run:
yarn build