-
-
Notifications
You must be signed in to change notification settings - Fork 356
[LazyImage] Abstract image content fetching #1781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
9b3c320
to
0a0d8fd
Compare
@@ -74,8 +78,10 @@ private function doEncode(string $filename, int $encodingWidth = 75, int $encodi | |||
|
|||
private function generatePixels(string $filename, int $encodingWidth, int $encodingHeight): array | |||
{ | |||
$imageContent = ($this->fetchImageContent)($filename); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just a quick check on the result ?
- $this->fetchImageContent ??= fn (string $filename) => file_get_contents($filename);
+ $this->fetchImageContent ??= file_get_contents(...); |
->setArguments([ | ||
new Reference('lazy_image.image_manager', ContainerInterface::NULL_ON_INVALID_REFERENCE), | ||
null, // $cache | ||
null, // $fetchImageContent | ||
]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like I can't set the 3rd argument if the 2nd argument has not been set, which can be the case if we have no cache configured, that's why I've changed to ->setArguments
Reviews have been applied, thanks :) |
Thank you Hugo. |
Hi,
This PR is a proposal for #1773, logic to fetch content image is now customizable thanks to closure, meaning that an end-user can use whatever solution he wants to fetch the image content (HttpClient, Flysystem, ...).
I'm not 100% about the
Closure::fromCallable(new Reference($config['fetch_image_content']))
tho