1. Go to this page and download the library: Download jsor/http-client-hints library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jsor / http-client-hints example snippets
$resolved = (new Jsor\HttpClientHints\Resolver())
->withAllowedHeaders([
// Process only Width and DPR headers
'Width',
'DPR',
])
->withMapping([
// Map Width header to w key
'width' => 'w',
// Needed to extract the height from the query params
// for recalculation depending on Width if present
'height' => 'h',
])
->resolve($_SERVER, $_GET)
;
if (isset($resolved['dpr'])) {
header('Content-DPR: ' . $resolved['dpr']);
header('Vary: DPR', false);
}
if (isset($resolved['w'])) {
header('Vary: Width', false);
}
// Use $resolved to generate thumbnails.
// If you use Glide (https://github.com/thephpleague/glide), this could look
// something like:
$server = League\Glide\ServerFactory::create([
'source' => 'path/to/source/folder',
'cache' => 'path/to/cache/folder',
]);
$server->outputImage($path, array_merge($_GET, $resolved));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.