0.0.3 • Published 4 years ago

strapi-provider-upload-cloudinary-folderoptions v0.0.3

Weekly downloads
32
License
SEE LICENSE IN LI...
Repository
github
Last release
4 years ago

strapi-provider-upload-cloudinary-folderoptions

This is an extended version of strapi-provider-upload-cloudinary

Configurations

Your configuration is passed down to the cloudinary configuration. (e.g: cloudinary.config(config)). You can see the complete list of options here

See the using a provider documentation for information on installing and using a provider. And see the environment variables for setting and using environment variables in your configs.

Example default_folder option has been added to the config to allow for uploading to a specific cloudinary folder by default. The file name can also be used to specify a folder structure that remains under the default_folder option or overrides the default_folder options.

For example:

  • example_app.png could be uploaded to the /default_folder/logos/apps cloudinary folder by having a default_folder option set and changing the file name to logos/apps/example_app.png

  • If you want to override the default_folder options, change the file name to /logos/apps/example_app.png. This would place the file under a cloudinary folder structure of /logos/apps instead of /default_folder/logos/apps

While Cloudinary can handle all the image size/cropping/quality/etc for you so that you don't have to turn on the "Enable responsive friendly upload" on Strapi, this will also take into consideration the different default sizing Strapi performs and place them in subfolder accordingly (e.g. thumbnail, small, medium, large)

./config/plugins.js

module.exports = ({ env }) => ({
  // ...
  upload: {
    provider: 'cloudinary-folderoptions',
    providerOptions: {
      cloud_name: env('CLOUDINARY_NAME'),
      api_key: env('CLOUDINARY_KEY'),
      api_secret: env('CLOUDINARY_SECRET'),
      default_folder: eng('CLOUDINARY_DEFAULT_FOLDER'),
    },
  },
  // ...
});

Resources

Links