Skip to content

Commit ff8ad03

Browse files
committed
updating readme, adding cloud name as input option
1 parent ea51975 commit ff8ad03

File tree

4 files changed

+117
-3
lines changed

4 files changed

+117
-3
lines changed

README.md

Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,111 @@
1-
# netlify-plugin-cloudinary
1+
# Cloudinary Netlify Plugin
2+
3+
Optimize and serve all images served in your Netlify site deploy with [Cloudinary](https://cloudinary.com/).
4+
5+
**This plugin is not officially supported by Cloudinary.**
6+
7+
## ⚡️ Getting Started
8+
9+
- Sign up for a free [Cloudinary](https://cloudinary.com/) account.
10+
11+
- Install the plugin:
12+
13+
```shell
14+
npm install netlify-plugin-cloudinary
15+
# or
16+
yarn add netlify-plugin-cloudinary
17+
```
18+
19+
- Add the plugin to your Netlify config:
20+
21+
```toml
22+
[[plugins]]
23+
package = "netlify-plugin-cloudinary"
24+
```
25+
26+
- Configure your Cloudinary Cloud Name:
27+
28+
```toml
29+
[[plugins]]
30+
package = "netlify-plugin-cloudinary"
31+
32+
[plugins.inputs]
33+
cloudName = "[Your Cloud Name]"
34+
```
35+
36+
By default, your images will served via the [fetch delivery method](https://cloudinary.com/documentation/fetch_remote_images).
37+
38+
## 🧰 Configuration
39+
40+
### Setting your Cloud Name
41+
42+
You have two options for setting your Cloud Name: plugin input or environment variable.
43+
44+
**Input**
45+
46+
Inside your Netlify config:
47+
48+
```toml
49+
[plugins.inputs]
50+
cloudName = "[Your Cloud Name]"
51+
```
52+
53+
**Environment Variable**
54+
55+
Inside your environment variable configuration:
56+
57+
```
58+
CLOUDINARY_CLOUD_NAME="[Your Cloud Name]"
59+
```
60+
61+
Learn how to [set environment variables with Netlify](https://docs.netlify.com/configure-builds/environment-variables/).
62+
63+
### Changing your Delivery Method
64+
65+
**fetch**
66+
67+
Default - no additional configuration needed.
68+
69+
Learn more about using delivering remote images with [fetch](https://cloudinary.com/documentation/fetch_remote_images).
70+
71+
**upload - Unsigned**
72+
73+
Unsigned uploads require an additional [Upload Preset](https://cloudinary.com/documentation/upload_presets) set up and configured in your Cloudinary account.
74+
75+
Inside your Netlify config:
76+
77+
```toml
78+
[[plugins]]
79+
package = "netlify-plugin-cloudinary"
80+
81+
[plugins.inputs]
82+
cloudName = "[Your Cloudinary Cloud Name]"
83+
deliveryMethod = "upload"
84+
uploadPreset = "[Your Cloudinary Upload Preset]"
85+
```
86+
87+
Learn more about [unsigned uploads](https://cloudinary.com/documentation/upload_images#unsigned_upload).
88+
89+
**upload - Signed
90+
91+
Signed uploads require you to set your API Key and API Secret as environment variables.
92+
93+
Inside your Netlify config:
94+
95+
```toml
96+
[[plugins]]
97+
package = "netlify-plugin-cloudinary"
98+
99+
[plugins.inputs]
100+
cloudName = "[Your Cloudinary Cloud Name]"
101+
deliveryMethod = "upload"
102+
```
103+
104+
Inside your environment variable configuration:
105+
106+
```
107+
CLOUDINARY_API_KEY="[Your Cloudinary API Key]"
108+
CLOUDINARY_API_SECRET="[Your Cloudinary API Secret]"
109+
```
110+
111+
Learn more about [signed uploads](https://cloudinary.com/documentation/upload_images#uploading_assets_to_the_cloud).

manifest.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: netlify-plugin-cloudinary
22
inputs:
3+
- name: cloudName
4+
required: false
5+
description: "Cloudinary Cloud Name - can be used as an input or environment variable via CLOUDINARY_CLOUD_NAME"
36
- name: deliveryType
47
required: false
58
description: "The method in which Cloudinary stores and delivers images (Ex: fetch, upload)"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "netlify-plugin-cloudinary",
3-
"version": "0.0.4",
3+
"version": "0.0.5",
44
"description": "",
55
"main": "src/index.js",
66
"scripts": {

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const cloudinary = require('cloudinary').v2;
88
* TODO
99
* - Track uploads to avoid uploading same image multiple times
1010
* - Handle srcset
11+
* - Delivery type for redirect via Netlify redirects
1112
*/
1213

1314
module.exports = {
@@ -16,7 +17,7 @@ module.exports = {
1617
const { PUBLISH_DIR } = constants;
1718
const { deliveryType, uploadPreset } = inputs;
1819

19-
const cloudName = process.env.CLOUDINARY_CLOUD_NAME;
20+
const cloudName = process.env.CLOUDINARY_CLOUD_NAME || inputs.cloudName;
2021
const apiKey = process.env.CLOUDINARY_API_KEY;
2122
const apiSecret = process.env.CLOUDINARY_API_SECRET;
2223

0 commit comments

Comments
 (0)