Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
701c747
render tag basics
jasonvarga May 27, 2024
593f677
dont assume url will be part of attributes
jasonvarga May 27, 2024
0d32716
glide manipulator
jasonvarga May 28, 2024
a15d439
stub imgix
jasonvarga May 28, 2024
d273a26
cp thumbnails use new manipulator and redirects
jasonvarga May 28, 2024
10ab8fa
existing image generator just offloads work onto new one (which was b…
jasonvarga May 28, 2024
b71be80
deprecations
jasonvarga May 28, 2024
2679e16
Merge branch '5.x' into image-manipulation
jasonvarga May 31, 2024
075c075
Merge branch '5.x' into image-manipulation
jasonvarga Jun 4, 2024
ae19f04
point to right class
jasonvarga Jun 5, 2024
1e36615
attributes
jasonvarga Jun 5, 2024
eb31de9
handle tag pair with asset
jasonvarga Jun 5, 2024
9d5dc3f
wip
jasonvarga Jun 5, 2024
269ca24
merge in asset data
jasonvarga Jun 5, 2024
6919af4
manipulator manager - ability to define them in config and extend wit…
jasonvarga Jun 5, 2024
6076eb6
render tag can specify a manipulator via the "using" param
jasonvarga Jun 5, 2024
f6926a4
use an enum
jasonvarga Jun 5, 2024
bda5cb9
pointing to wrong classes
jasonvarga Jun 5, 2024
54c287b
wrong method
jasonvarga Jun 5, 2024
d95c7b2
initial imgix driver
jasonvarga Jun 5, 2024
fc9b988
imgix dependency
jasonvarga Jun 5, 2024
840d9ef
url builder returns 1s which doesnt work. hack it in for now.
jasonvarga Jun 13, 2024
82c3763
Merge branch '5.x' into image-manipulation
jasonvarga Jul 11, 2024
6f2007e
phpunit attributes
jasonvarga Jul 11, 2024
c0fd752
Source classes ...
jasonvarga Jul 11, 2024
cd57663
Merge branch '5.x' into image-manipulation
jasonvarga Jul 29, 2024
2f15cec
fix source here
jasonvarga Jul 29, 2024
af27ede
null
jasonvarga Jul 29, 2024
f6c780e
Merge branch '5.x' into image-manipulation
jasonvarga Sep 13, 2024
32b4bc2
manipulator can be set per asset container and access through source
jasonvarga Sep 13, 2024
c0db6ea
Change setParams to addParams ...
jasonvarga Sep 13, 2024
279d56b
focal point params get their own method
jasonvarga Sep 13, 2024
161be8e
use method now that the property is private
jasonvarga Sep 13, 2024
17b6a98
implement focal point method for imgix
jasonvarga Sep 13, 2024
1d7a104
initial cloudflare driver
jasonvarga Sep 13, 2024
2afa449
fix types
jasonvarga Sep 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"ajthinking/archetype": "^1.0.3 || ^2.0",
"composer/semver": "^3.4",
"guzzlehttp/guzzle": "^6.3 || ^7.0",
"imgix/imgix-php": "^4.1",
"james-heinrich/getid3": "^1.9.21",
"laravel/framework": "^10.40 || ^11.0",
"laravel/prompts": "^0.1.16",
Expand Down
18 changes: 18 additions & 0 deletions config/image_manipulation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

return [
'default' => 'glide',

'manipulators' => [
'glide' => [
'driver' => 'glide',
'cache' => public_path('img'),
'url' => 'img',
],

'imgix' => [
'driver' => 'imgix',
'domain' => 'example.imgix.net',
],
],
];
1 change: 1 addition & 0 deletions routes/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
});
}

/* @deprecated The new Glide implementation does not use the HTTP API. */
if (Glide::shouldServeByHttp()) {
require __DIR__.'/glide.php';
}
Expand Down
9 changes: 9 additions & 0 deletions src/Assets/AssetContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class AssetContainer implements Arrayable, ArrayAccess, AssetContainerContract,
protected $sourcePreset;
protected $warmPresets;
protected $searchIndex;
protected $imageManipulator;
protected $afterSaveCallbacks = [];
protected $withEvents = true;
protected $sortField;
Expand Down Expand Up @@ -675,6 +676,14 @@ public function searchIndex($index = null)
->args(func_get_args());
}

public function imageManipulator($manipulator = null)
{
return $this
->fluentlyGetOrSet('imageManipulator')
->getter(fn ($manipulator) => Image::driver($manipulator))
->args(func_get_args());
}

public static function __callStatic($method, $parameters)
{
return Facades\AssetContainer::{$method}(...$parameters);
Expand Down
4 changes: 4 additions & 0 deletions src/Contracts/Imaging/ImageManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

use Statamic\Contracts\Assets\Asset;

/**
* @deprecated New image manipulation methods have been introduced.
* @see Manipulator
*/
interface ImageManipulator
{
/**
Expand Down
48 changes: 48 additions & 0 deletions src/Contracts/Imaging/Manipulator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace Statamic\Contracts\Imaging;

use Statamic\Imaging\Manipulators\Sources\Source;

interface Manipulator
{
/**
* Sets the source image to be manipulated.
*/
public function setSource(Source $source): self;

/**
* Adds manipulations to be performed.
*/
public function addParams(array $params): self;

/**
* Adds the appropriate params that would control focal point cropping.
*/
public function addFocalPointParams(float $x, float $y, float $z): self;

/**
* Gets the manipulations to be performed.
*/
public function getParams(): array;

/**
* Gets the available manipulation parameters.
*/
public function getAvailableParams(): array;

/**
* Gets the URL of the manipulated image.
*/
public function getUrl(): string;

/**
* Reads the manipulated image and returns it as a data URL.
*/
public function getDataUrl(): string;

/**
* Get attributes about the image (e.g. width, height)
*/
public function getAttributes(): array;
}
4 changes: 4 additions & 0 deletions src/Contracts/Imaging/UrlBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

namespace Statamic\Contracts\Imaging;

/**
* @deprecated New image manipulation methods have been introduced.
* @see Manipulator
*/
interface UrlBuilder
{
/**
Expand Down
5 changes: 4 additions & 1 deletion src/Facades/Glide.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Support\Facades\Facade;
use Statamic\Imaging\GlideManager;
use Statamic\Imaging\Manipulators\GlideManipulator;

/**
* @method static \League\Glide\Server server(array $config = [])
Expand All @@ -17,7 +18,9 @@
* @method static array normalizeParameters($params)
* @method static void generateHashUsing(\Closure $callback)
*
* @see \Statamic\Imaging\GlideManager
* @deprecated Glide should be accessed through its manipulation class.
* @see GlideManipulator
* @see GlideManager
*/
class Glide extends Facade
{
Expand Down
32 changes: 6 additions & 26 deletions src/Http/Controllers/CP/Assets/ThumbnailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,16 @@

use Illuminate\Support\Facades\Cache;
use League\Flysystem\UnableToReadFile;
use League\Glide\Server;
use Statamic\Exceptions\NotFoundHttpException;
use Statamic\Facades\Asset;
use Statamic\Facades\Config;
use Statamic\Facades\Image;
use Statamic\Http\Controllers\Controller;
use Statamic\Imaging\ImageGenerator;
use Statamic\Imaging\Manipulators\Sources\Source;
use Statamic\Statamic;

class ThumbnailController extends Controller
{
/**
* @var Server
*/
protected $server;

/**
* @var ImageGenerator
*/
protected $generator;

/**
* @var \Statamic\Contracts\Assets\Asset
*/
Expand All @@ -45,12 +34,6 @@ class ThumbnailController extends Controller
*/
protected $mutex;

public function __construct(Server $server, ImageGenerator $generator)
{
$this->server = $server;
$this->generator = $generator;
}

/**
* Display the thumbnail.
*
Expand All @@ -69,10 +52,7 @@ public function show($asset, $size = null, $orientation = null)
return $placeholder;
}

return $this->server->getResponseFactory()->create(
$this->server->getCache(),
$this->generate()
);
return redirect($this->generate());
}

/**
Expand Down Expand Up @@ -108,10 +88,10 @@ private function generate()
throw new \Exception('Invalid preset');
}

$path = $this->generator->generateByAsset(
$this->asset,
$preset ? ['p' => $preset] : []
);
$path = $this->asset->container()->imageManipulator()
->setSource(Source::from($this->asset))
->setParams($preset ? ['p' => $preset] : [])
->getUrl();
} catch (UnableToReadFile $e) {
throw new NotFoundHttpException;
} finally {
Expand Down
3 changes: 3 additions & 0 deletions src/Http/Controllers/GlideController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
use Statamic\Imaging\ImageGenerator;
use Statamic\Support\Str;

/**
* @deprecated The new Glide implementation does not use the HTTP API.
*/
class GlideController extends Controller
{
/**
Expand Down
4 changes: 4 additions & 0 deletions src/Imaging/AssetNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

namespace Statamic\Imaging;

/**
* @deprecated
* @see \Statamic\Exceptions\AssetNotFoundException
*/
class AssetNotFoundException extends \Exception
{
}
5 changes: 5 additions & 0 deletions src/Imaging/GlideImageManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
use Statamic\Contracts\Imaging\ImageManipulator;
use Statamic\Contracts\Imaging\UrlBuilder;
use Statamic\Facades\Asset as AssetAPI;
use Statamic\Imaging\Manipulators\GlideManipulator;

/**
* @deprecated New image manipulation methods have been introduced.
* @see GlideManipulator
*/
class GlideImageManipulator implements ImageManipulator
{
/**
Expand Down
5 changes: 5 additions & 0 deletions src/Imaging/GlideManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
use League\Glide\ServerFactory;
use Statamic\Facades\Config;
use Statamic\Facades\Image;
use Statamic\Imaging\Manipulators\GlideManipulator;
use Statamic\Imaging\ResponseFactory as LaravelResponseFactory;
use Statamic\Support\Str;

/**
* @deprecated Glide should be accessed through its manipulation class.
* @see GlideManipulator
*/
class GlideManager
{
private Closure $customHashCallable;
Expand Down
5 changes: 5 additions & 0 deletions src/Imaging/GlideUrlBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
use League\Glide\Urls\UrlBuilderFactory;
use Statamic\Contracts\Assets\Asset;
use Statamic\Facades\URL;
use Statamic\Imaging\Manipulators\GlideManipulator;
use Statamic\Support\Str;

/**
* @deprecated URL building is now done in dedicated manipulator classes.
* @see GlideManipulator
*/
class GlideUrlBuilder extends ImageUrlBuilder
{
/**
Expand Down
Loading