-
Notifications
You must be signed in to change notification settings - Fork 378
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
Simple API for creating thumbnail #142
Comments
Just define a new filter for your thumbnail needs:
Then just reference the new filter in your twig template like this: |
Or, just use the example from the docs... |
I know but I talk about a use case where I plan to cache the image directly after uploading. For that I like to use a simple API. The Current method is a little bit more complex then what I request here. For example: why do I need to add a Request object? What if I use the cache generating within a console command? |
You're going to have to be clearer on what functionality you require. When I read your initial comment it is the requirements for the existing thumbnail filter. |
Like I said only on upload base is something different. But I think only because the bundle is designed on request base there is no point to extend it to support generating with an API too since the code for generating a thumbnail exists already. |
There is an API, already. It's the controller itself (see https://github.com/liip/LiipImagineBundle#using-the-controller-as-a-service). You can simply upload your image anywhere, add a Does this work for you, what's missing, what do you expect? |
I know but I would like to see something like that: ThumbnailManager::create($relativePath, $filterName) I do not understand why I should pass the request object within my thumbnail generating while using the Controller as a service. |
Ah, now I got your point. I will create a PR for this kind of entry point. |
@fkrauthan Could you check the #150, does it work for you, anything missing? This requires you to manually place those images according to your |
An example, how you could use this in a command: class GenerateCachedImagesCommand extends ContainerAwareCommand
{
protected function configure()
{
// ..
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$filename = ''; // the absolute path of the file
$imagine = $this->getContainer()->get('liip_imagine');
$filterManager = $this->getContainer()->get('liip_imagine.filter.manager');
$image = $imagine->open($filename);
$image = $filterManager->applyFilter($image, 'thumbnail');
// process filtered image
}
} |
Yeah something like that looks good. |
Merged; |
I know this is closed, but I searched for a solution and could not find it, so I am going to put it here. This is how I got my thumbnail saved locally and return the filename of the thumbnail.
|
I like to request a simple service to create a thumbnail. As parameter it would be good if i just give the path (like in a twig template) and the name of the filter. And then it auto generate the specific thumbnail.
The text was updated successfully, but these errors were encountered: