Example usage:
$server = 'http://thumbor.example.com';
$secret = 'my-secret-key';
Thumbor\UrlBuilder::construct($server, $secret, 'http://images.example.com/llamas.jpg')
Apply commands
->fitIn(320, 240)
Add filters
->addFilter('brightness', 42)
Construct and return Url
->build();
If you coerce an instance of this class to String, you get the string
representation of the URL.
See https://github.com/globocom/thumbor/wiki/Usage for all available options.
public function testUrl() { $server = 'http://thumbor.example.com'; $secret = 'butts'; $original = 'http://example.com/llamas.jpg'; $builder = BuilderFactory::construct($server, $secret)->url($original); $expected = Builder::construct($server, $secret, $original); $this->assertEquals($expected, $builder); }
/** * Request metadata endpoint * * @param \Thumbor\Url\Builder $url * @param array $args * * @return void */ protected function metadataOnly(Builder $url, $args) { $url->metadataOnly($args); }
public function testToString() { $url = (string) Builder::construct('http://thumbor.example.com', 'butts', 'http://example.com/llamas.jpg')->fitIn(320, 240)->smartCrop(true)->addFilter('brightness', 42); $expected = 'http://thumbor.example.com/dgzk7MVde2RUq5Hbq40FvfRdno0=/fit-in/320x240/smart/filters:brightness(42)/http://example.com/llamas.jpg'; $this->assertEquals($expected, $url); }