strapi-provider-upload-imagekit
v5.11.13
Published
ImageKit provider for Strapi CMS
Readme
Future of the plugin
[!IMPORTANT] Imagekit team has released their own plugin to the Strapi marketplace. I expect they will make a much better effort of developing and maintaining their plugin than I did so please consider switching to the official plugin for better intergration and support.
That said, this plugin will remain available for anyone who is still using it or wants to use it instead of the official plugin. I will continue to maintain it until Strapi or Imagekit introduce breaking changes which would require too much time/effort to fix.
Thank you to everyone who has contributed to this plugin, reported bugs, and helped improve it in one way or another.
ImageKit provider for the Strapi Upload plugin
[!TIP] Consult the compatibility table if using previous versions of Strapi.
| Strapi version | Compatible provider | | -------------- | ------------------- | | v3 | v0.x.x | | v4 | v4.x.x | | v5 | v5.x.x |
Installation
1. Install via npm or yarn
npm install strapi-provider-upload-imagekit --saveor
yarn add strapi-provider-upload-imagekit2. Add or modify the plugins configuration file
Global configuration file is located in ./config/plugins.js
Environment configuration files are located in ./config/env/{env}/plugins.js
For more information please check the official documentation.
3. Define global variables
Example .env:
IMAGEKIT_PUBLIC_KEY=ed6445336472aef39084720adcf903b9
IMAGEKIT_PRIVATE_KEY=afbca80df2ec032de664aefb3a8579b7
IMAGEKIT_URL_ENDPOINT=https://ik.imagekit.io/username
IMAGEKIT_FOLDER=/production/images
IMAGEKIT_BASE_URL=ik.imagekit.io4. Add plugin configuration
Example ./config/plugins.js:
export default ({env}) => ({
upload: {
config: {
provider: "strapi-provider-upload-imagekit", // Community providers need to have the full package name
providerOptions: {
publicKey: env('IMAGEKIT_PUBLIC_KEY'),
privateKey: env('IMAGEKIT_PRIVATE_KEY'),
urlEndpoint: env('IMAGEKIT_URL_ENDPOINT'),
// Optional
params: {
folder: env('IMAGEKIT_FOLDER'),
}
}
}
}
});5. Setting up strapi::security middlewares to prevent contentSecurityPolicy URL blocking
Modify ./config/middleware.js:
export default ({env}) => ([
// ...
{
name: 'strapi::security',
config: {
contentSecurityPolicy: {
useDefaults: true,
directives: {
'connect-src': ["'self'", 'https:'],
'img-src': ["'self'", 'data:', 'blob:', env('IMAGEKIT_BASE_URL')],
'media-src': ["'self'", 'data:', 'blob:', env('IMAGEKIT_BASE_URL')],
upgradeInsecureRequests: null,
},
},
},
},
]);