Intervention / imagecache

Caching extension for the Intervention Image Class
https://image.intervention.io/v2/usage/cache
MIT License
637 stars 118 forks source link

Not working with external routing links #40

Closed kremsy closed 9 years ago

kremsy commented 9 years ago

Hello,

I try to cache for example from this url: http://sm.mania-exchange.com/maps/screenshot/normal/6264

I tried to set this in $image->make() but it always returns the error:

"Unable to init from given binary data. "

Also tried with: http://sm.mania-exchange.com/maps/screenshot/normal/6264?.jpg

It would be amazing if you can tell me an solution for this problem :).

olivervogel commented 9 years ago

Mania Exchange blocks EVERY request that contains an EMPTY USER AGENT. You MUST send a VALID USER AGENT.

I would fetch the image with Guzzle (include user-agent) and pass it to Intervention Image after that.

kremsy commented 9 years ago

can't you include a way to send user-agent from the lib as well?

Well I solved it now like this:;

{ //Check if file locally exists if(file_exists(public_path("images/mx-screenshots/") .$filename . ".jpg")){ $file = "images/mx-screenshots/" . $filename . ".jpg"; }else{ //Store file on harddrive $options = array('http' => array('user_agent' => 'paragon league')); $context = stream_context_create($options); $file = file_get_contents('http://sm.mania-exchange.com/maps/screenshot/normal/' . $filename, false, $context); file_put_contents(public_path("images/mx-screenshots/") .$filename . ".jpg", $file); } $image->make($file); }