Created
August 8, 2019 12:34
-
-
Save jbrooksuk/4eeb5adba6b786689ac91b39c880e0ad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Middleware; | |
use Closure; | |
use Illuminate\Http\Request; | |
use Illuminate\Support\Facades\Config; | |
class ClientHint | |
{ | |
/** | |
* Handle an incoming request. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Closure $next | |
* | |
* @return mixed | |
*/ | |
public function handle(Request $request, Closure $next) | |
{ | |
if (strpos($request->header('accept'), 'image/webp')) { | |
$defaults = Config::get('images.defaults'); | |
Config::set('images.defaults', array_merge($defaults, [ | |
'fm' => 'webp', | |
])); | |
} | |
return $next($request); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment