jimmynicol / image-resizer

On-the-fly image resizing using Node.js and GraphicsMagick. Heroku Ready!
MIT License
339 stars 104 forks source link

Support simple external sources through environment variables #61

Closed wjordan closed 9 years ago

wjordan commented 9 years ago

This PR adds the ability to specify additional external sources through environment variables. cf. the discussions in #24, #16 (used mariusa's code as a starting point)

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:

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

translates to:

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

No tests yet beyond the added image to index.html - could use guidance on how to add more robust tests for this sort of feature. Hope someone finds this helpful!

jimmynicol commented 9 years ago

So I had been avoiding supporting external sources with some previous requests, however I really like the whitelist approach here. Thanks again for your effort!