Skip to content

an extension of the strapi-provider-upload-cloudinary that allows for a default_folder option in the config as well as using the file name to define folder structure.

License

Notifications You must be signed in to change notification settings

VerdeCircle/strapi-provider-upload-cloudinary-folderoptions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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 /[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 at the time of upload, change the file name to /logos/apps/example_app.png. This would upload 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)

Starting Cloudinary Starting Cloudinary

Upload files to root by adding /logos/apps/ to the file name Upload Asset in Strapi with desired folder strcuture

And the result is... New Folder in Cloudinary root New Folder in Cloudinary root

Files in directory structure specified Files in directory structure specified ^^^ In this case, we have "Enable responsive friendly upload" set to on in Strapi>Settings>Media Library

Strapi Media Library Settings

Upload files using the default_folder option AND even adding your own folder structure Strapi Asset Upload default_folder & additional folder structure

And the result is... default_folder (which is set in .env file) created on cloudinary root with file specific sub folders as well default_folder option

Upload to default_folder only Strapi Upload to default_folder only

Files placed in root of default_folder on Cloudinary Root of default_folder

./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: env('CLOUDINARY_DEFAULT_FOLDER'),
    },
  },
  // ...
});

Resources

Links

About

an extension of the strapi-provider-upload-cloudinary that allows for a default_folder option in the config as well as using the file name to define folder structure.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published