bugfixdev-ghost-imagekit-store
v0.0.9
Published
ImageKit Ghost Storage adapter forked from offical https://github.com/imagekit-developer/ghost-imagekit-store
Downloads
1
Readme
bugfix.dev Changes.
forked from offical https://github.com/imagekit-developer/ghost-imagekit-store.
Fixed bug/issue.
- Converts windows and posix path to always posix path on image save.
- No need to set GHOST_CONTENT env variable on ghost startup.
- No need of updatedAt in image url, if useUniqueFileName = true.
- Working 13 tests cases.
To Use Image Transformation Dynamically use img_url.js (frontend helper).
ImageKit Ghost Storage
ImageKit's Ghost storage adapter.
Features
- 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
.
Installation
Using yarn
- Go into your Ghost project's root directory.
- Install the adapter:
yarn add bugfixdev-ghost-imagekit-store
cp node_modules/bugfixdev-ghost-imagekit-store/dist/src content/adapters/storage/imagekit/
- Configure Ghost's config file.
Install on Docker
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 bugfixdev-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/bugfixdev-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/"
}
Configuration
Check out config.development.json 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": true,
"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
.
Recommended configuration
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.
ImageKit dashboard settings
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.
Development
To install, run:
yarn install
To run tests and generate coverage, run:
yarn test
To build, run:
yarn build