Skip to content

Commit 6f3c658

Browse files
authored
Merge pull request #17 from teohhanhui/external-regex
Mention regex support for external source
2 parents 8cbf21e + 32bcf67 commit 6f3c658

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

README.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -222,20 +222,26 @@ translates to:
222222

223223
It is possible to bring images in from external sources and store them behind your own CDN. This is very useful when it comes to things like Facebook or Vimeo which have very inconsistent load times. Each external source can still enable any of the modification parameters list above.
224224

225-
In addition to the provided external sources, you can easily add your own basic external sources using `EXTERNAL_SOURCE_*` environment variables. For example, to add Wikipedia as an external source, set the following environment variable:
225+
In addition to the provided external sources, you can easily add your own external sources using `EXTERNAL_SOURCE_*` environment variables. For example, to add Wikipedia as an external source, set the following environment variable:
226226

227227
```
228228
EXTERNAL_SOURCE_WIKIPEDIA: 'https://upload.wikimedia.org/wikipedia/'
229229
```
230230

231-
Then you can request images beginning with the provided path using the `ewikipedia` modifier, eg:
231+
Then you can request images beginning with the provided path prefix using the `ewikipedia` modifier, eg:
232232

233233
http://my.cdn.com/ewikipedia/en/7/70/Example.png
234-
234+
235235
translates to:
236236

237237
https://upload.wikimedia.org/wikipedia/en/7/70/Example.png
238238

239+
You may also use [Regular Expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp). Just use the same syntax as regex literals in JS. For example, to match any URLs matching `*.googleusercontent.com`:
240+
241+
```
242+
EXTERNAL_SOURCE_GOOGLEUSERCONTENT=/https?:\/\/.+\.googleusercontent\.com\//i
243+
```
244+
239245
It is worth noting that Twitter requires a full set of credentials as you need to poll their API in order to return profile pics.
240246

241247
A shorter expiry on images from social sources can also be set via `IMAGE_EXPIRY_SHORT` env var so they expiry at a faster rate than other images.

0 commit comments

Comments
 (0)