@@ -9,21 +9,21 @@ all plans.
9
9
## Enabling the Image CDN
10
10
11
11
To enable the Image CDN, you should set the environment variable
12
- ` NETLIFY_IMAGE_CDN ` to ` true ` . You will also need to declare allowed image URL
13
- patterns in ` netlify.toml ` :
12
+ ` NETLIFY_IMAGE_CDN ` to ` true ` . You will also need to declare allowed remote
13
+ image regular expression patterns in ` netlify.toml ` :
14
14
15
15
``` toml
16
16
[build .environment ]
17
17
NETLIFY_IMAGE_CDN = " true"
18
18
19
19
[images ]
20
20
remote_images = [
21
- ' https:/ /example1.com/ *' ,
22
- ' https:/ /example2.com/ *'
21
+ ' ^ https:\\/\\ /example1\\ .com\\/. *' ,
22
+ ' ^ https:\\/\\ /example2\\ .com\\/. *'
23
23
]
24
24
```
25
25
26
- Exact URL patterns to use will depend on CMS you use and possibly your
26
+ Exact remote image pattern to use will depend on CMS you use and possibly your
27
27
configuration of it.
28
28
29
29
- ` gatsby-source-contentful ` :
@@ -33,7 +33,7 @@ configuration of it.
33
33
remote_images = [
34
34
# <your-contentful-space-id> is specified in the `spaceId` option for the
35
35
# gatsby-source-contentful plugin in your gatsby-config file.
36
- " https:/ /images.ctfassets.net/<your-contentful-space-id>/ *"
36
+ " ^ https:\\ / \\ /images\\ .ctfassets\\ .net\\ /<your-contentful-space-id>\\ /. *"
37
37
]
38
38
```
39
39
@@ -44,7 +44,7 @@ configuration of it.
44
44
remote_images = [
45
45
# <your-drupal-base-url> is speciafied in the `baseUrl` option for the
46
46
# gatsby-source-drupal plugin in your gatsby-config file.
47
- " <your-drupal-base-url>/ *"
47
+ " ^ <your-drupal-base-url>\\ /. *"
48
48
]
49
49
```
50
50
@@ -56,14 +56,21 @@ configuration of it.
56
56
# <your-wordpress-url> is specified in the `url` option for the
57
57
# gatsby-source-wordpress plugin in your gatsby-config file.
58
58
# There is no need to include `/graphql in the path here`
59
- " <your-wordpress-url>/ *"
59
+ " ^ <your-wordpress-url>\\ /. *"
60
60
]
61
61
```
62
62
63
63
Above examples are the most likely ones to be needed. However if you configure
64
64
your CMS to host assets on different domain or path, you might need to adjust
65
65
the patterns accordingly.
66
66
67
+ Keep in mind that you will need to escape special regular expression symbols to
68
+ avoid creating too permisible patterns:
69
+
70
+ - ` . ` should be escaped as ` \\. ` (dot)
71
+ - ` / ` should be escaped as ` \\/ ` (slash)
72
+ - your rule should start with ` ^ ` so domain matching is exact
73
+
67
74
## How it works
68
75
69
76
When using the Image CDN, Gatsby generates URLs of the form
0 commit comments