Skip to content

Commit

Permalink
Merge pull request #17 from teohhanhui/external-regex
Browse files Browse the repository at this point in the history
Mention regex support for external source
  • Loading branch information
teohhanhui authored Jul 4, 2016
2 parents 8cbf21e + 32bcf67 commit 6f3c658
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,20 +222,26 @@ translates to:

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.

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:
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:

```
EXTERNAL_SOURCE_WIKIPEDIA: 'https://upload.wikimedia.org/wikipedia/'
```

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

http://my.cdn.com/ewikipedia/en/7/70/Example.png

translates to:

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

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`:

```
EXTERNAL_SOURCE_GOOGLEUSERCONTENT=/https?:\/\/.+\.googleusercontent\.com\//i
```

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.

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.
Expand Down

0 comments on commit 6f3c658

Please sign in to comment.