Select one of multiple domains
sgatz opened this issue · comments
Hi, I love this package, but I have a different need. I have multiple imgix domains used in different parts of my laravel app. I'd love to be able to pass the domain as a param something like: Imgix::createUrl('test.jpg', ['w' => 100, 'h' => 100], 'domain.imgix.net'); is there a simple way to do this or add this?
Hey, @sgatz. You dynamically override the imgix.domain
config parameter.
echo imgix('test.jpg', ['w' => 100, 'h' => 100]);
// Prints out (assuming your initial domain is domain.imgix.net):
// http://domain.imgix.net/test.jpg?w=100&h=100
// Dynamically override imgix.domain config parameter
config(['imgix.domain' => 'other.imgix.net']);
echo imgix('test.jpg', ['w' => 100, 'h' => 100]);
// Prints out (assuming your initial domain is domain.imgix.net):
// http://other.imgix.net/test.jpg?w=100&h=100
That'd be great.
Seems a bit odd to pass it as an imgix
parameter though, inside of the array.
Maybe an optional third parameter?
imgix('test.jpg', ['w' => 100, 'h' => 100], 'other.imgix.net');
I know that's a bit less sustainable in the long run and maybe including it inside of the parameters gives us more flexibility.
So, maybe we can go with your proposal.
Hi @nonoesp, sounds okay to me, could you please prep a PR for that?
I'll add this to my backlog and see if I get the time. If anyone wants to give it a go. Feel free!