-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Glide integration #49
Conversation
Excellent! Glide integration was indeed on my radar. One thing I'd like to do is make this feature more generic. Here's what I'm thinking: namespace Zenstruck\Filesystem\Feature;
use Zenstruck\Filesystem\Node\File\Image;
use Zenstruck\Uri;
interface ImageTransformationUrl
{
public function imageTransformationUrlFor(Image $file, mixed $options = []): Uri;
} Then in My reasoning here is there are several implementations we could have:
I wouldn't want to have a new WDYT? BTW, is transformation the best term to use here? |
I'm not super familiar with Glide but one thing that I think we'd need as well is some kind of |
I think we actually don't. Glide is already built on top of Flysystem and requires configuration by it's own. And when it's configured all that we need is an instance of About making this feature more generic - I'm all in :D this is somehow on par with image manipulation interface I have in my mind right now (expect PR soon 😉 ). And about the naming. I would love for this to be short, because long method names look weird in Twig templates to me. How about calling it "thumbnailers" and use |
But this would require configuring flysystem twice, no? Once for glide and once for this library.
I think I'd still like to call the feature interface (naming stuff well is an obsession of mine - maybe a sickness tbh...)
Did you take a look at #15? I'd really like to have this library able to transform the images itself (using Imagine or Intervention - they are the most popular libraries I think). I was thinking something like: $image = $filesystem->image('some/image.png)
->transform(function(ImagineImage|IterventionImage $image): ImagineImage|IterventionImage {
return $image->transformation1()->transformation2();
})
;
$image; // ?? \SplFileInfo
My idea was this |
I have made changes to the feature and classes names as suggested. Hopefully they are generic enough right now :) I didn't change Sf bridge configuration for now as I'm unsure on how to get this right, so input welcome :)
The way I see using this lib, flysystem and glide it does not, but maybe I'm missing something. I see all of those working in a tandem like this:
|
Ah, ok, I understand now. My intention was to have this library/bundle as an alternative to That being said, this bundle can be used standalone but I will look into how we can better integrate with flysystem-bundle (#53). |
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 good! Just a few minor things.
I think the current configuration is fine, assuming we have good integration with flysystem-bundle. I do still think there should be a possibility of using this bundle and glide standalone. Something like: zenstruck_filesystem:
filesystems:
images: 'some.dsn'
glide.cache: 'some.dsn'
glide_server:
source: images # filesystem name from above
cache: glide.cache # filesystem name from above
# ... other ServerFactory options Basically create a But I'll save this for later. |
BTW, don't worry about getting bogged down fixing failing sca/cs jobs. Tests pass so that's fine. |
Co-authored-by: Kevin Bond <kevinbond@gmail.com>
Co-authored-by: Kevin Bond <kevinbond@gmail.com>
Co-authored-by: Kevin Bond <kevinbond@gmail.com>
Co-authored-by: Kevin Bond <kevinbond@gmail.com>
…l.php Co-authored-by: Kevin Bond <kevinbond@gmail.com>
Co-authored-by: Kevin Bond <kevinbond@gmail.com>
Co-authored-by: Kevin Bond <kevinbond@gmail.com>
Let's drop the wiring in the Symfony bundle for now. Once we have more implementations of this feature available, we can re-evaluate how it should be configured. My plan is to have a zenstruck_filesystem:
filesystems:
public:
dsn: ...
features:
Zenstruck\Filesystem\Feature\TransformImageUrl: some.service |
I am closing this in favor of #79 |
Given the simplicity of features in this library I found it simple to add glide server integration. Given glide popularity I believe it is worth to be available out of the box.
It is implemented by
UrlBuilderGlideUrlFeature
, which takes Glide ownUrlBuilder
as an argument and uses it to generate URLs for images (with URL signing when configured and all that stuff).Usage is as simple as calling
$image->glideUrl(['w' => 100, 'h' => 100])
.I chose to add a new method because it is beneficial to be able to call both
url()
andglideUrl()
on the same image and get different results (path to original image versus path to "glided" image).