Closed Lawondyss closed 9 years ago
I am not sure I follow.
You can do whatever you want in provider. See https://github.com/dotblue/nette-webimages/blob/master/examples/DefaultImageProvider.php
OK, but why Generator save image from Provider? https://github.com/dotblue/nette-webimages/blob/master/src/Generator.php#L88
Because the main goal of this library is that you process image only once.
When you access /images/dog.jpg and it does not exist it fires the provider which returns image and this images is saved to location /images/dog.jpg
Next time someonte access /images/dog.jpg the provider (whole nette application) is not called at all because web server returns it immediately.
And why not save the image in the provider?
Why would you do that? It would be the same code in every provider. Provider does not care where it will be saved or if it will be saved at all. Provider just returns image in exact format.
Because I cannot over save the image. Example: I have two provider. First return thumbnail from expected picture. Second return placeholder if expected picture not exist. If Generator save the placeholder, then first provider never save new picture when expected picture already exists.
BTW sorry for the bad title of the Issue.
Well, if picture exists and it's requested for the first time, it will generate and save thumbnail. If it doesn't exist, placeholder will be saved instead. If you get the image later and you want to change placeholder to correctly generated thumbnail, you can either:
OK, thanks. I suppose you not change your opinion about moving deciding of saving to a provider.
I suppose you not change your opinion about moving deciding of saving to a provider.
Well, why should I :) ? At this moment, without further arguments, I think it would break the whole architecture (it just wouldn't make any sense).
Why not create thumbnails in the provider? The provider generate only path to the picture, but I want to have in control the method of obtaining thumbnails.