|
1 |
| -A minimal PHP client for [Thumbor][1]. |
| 1 | +# Phumbor |
2 | 2 |
|
3 |
| -Usage: |
4 |
| -```php |
5 |
| -$original = 'http://images.example.com/llamas.jpg'; |
6 |
| -$commands = array('fit-in', '640x480', 'filters:fill(green)'); |
| 3 | +A minimal PHP client for generating [Thumbor][1] URLs. |
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +You construct a `Thumbor\Url` using a `Thumbor\Url\Builder`: |
7 | 8 |
|
| 9 | +```php |
8 | 10 | $server = 'http://thumbor.example.com:1234';
|
9 | 11 | $secret = 'my-secret-key';
|
10 | 12 |
|
11 |
| -echo new \Thumbor\Url($original, $commands, $server, $secret); |
| 13 | +echo Thumbor\Url\Builder::construct($server, $secret) |
| 14 | + ->from('http://images.example.com/llamas.jpg') |
| 15 | + ->fitIn(640, 480) |
| 16 | + ->addFilter('fill', 'green'); |
| 17 | + |
12 | 18 | // => http://thumbor.example.com:1234/mYdVBN25gyqUGD3QRsI9_rl1IxQ=/fit-in/640x480/filters:fill(green)/http%3A%2F%2Fimages.example.com%2Fllamas.jpg
|
13 | 19 | ```
|
14 | 20 |
|
| 21 | +To reuse your server/secret combination, create a `Thumbor\Url\BuilderFactory`: |
| 22 | + |
| 23 | +```php |
| 24 | +$thumbnailUrlFactory = Thumbor\Url\BuilderFactory::construct($server, $secret); |
| 25 | + |
| 26 | +echo $thumbnailUrlFactory |
| 27 | + ->fromUrl('http://images.example.com/llamas.jpg') |
| 28 | + ->fitIn(640, 480) |
| 29 | + ->addFilter('fill', 'green'); |
| 30 | + |
| 31 | +echo $thumbnailUrlFactory |
| 32 | + ->fromUrl('http://images.example.com/butts.png') |
| 33 | + ->crop(20, 20, 300, 300) |
| 34 | + ->valign('middle'); |
| 35 | + |
| 36 | +// etc |
| 37 | +``` |
| 38 | + |
| 39 | +## License |
| 40 | + |
| 41 | +MIT; see [`LICENSE`][2] |
| 42 | + |
15 | 43 | [1]: https://github.com/globocom/thumbor
|
| 44 | + [2]: https://github.com/99designs/phumbor/blob/master/LICENSE |
0 commit comments