Answer the question
In order to leave comments, you need to log in
Best practices for generating thumbnails for galleries?
Hi all!
Now I'm making a gallery, and a small question arose about how to organize the generation, and work in general, with previews.
Previously, I did all this in the following way:
- I immediately generated previews when uploading images
- saved them like regular (original) images in the gallery folder
- The object had getPreview and setPreview methods, in addition to getImage and setImage for a regular size image.
Now, studying Symphony, I often see something like this:
- previews are generated when accessing them, by calling the appropriate filter in the View. On the example of Symphony, this is something like
<img src="{{ 'image.jpg' | imagine_filter('my_thumb') }}" />
Answer the question
In order to leave comments, you need to log in
If there are many images, different sizes too, and access to them is not very frequent, then it is more profitable to store only one image of the maximum size and resize on the fly nginx.org/ru/docs/http/ngx_http_image_filter_modul...
Thanks to all who responded! I'll add the question then.
If we need to generate a preview, then generating it on the fly in the View, without changing the Model and Gallery Controller, is probably good practice.
But what if the picture should have several options for the main sizes. Let's say that to ensure the adaptability of the picture, you need 2 sizes + preview. And for adaptive images, sometimes it is required not only to reduce the image, but also, for example, crop it a little from the left / right, while changing the aspect ratio. Then, probably, it's better to generate a preview "on the fly" and not save it in the model and database, but for important sizes, implement the generation "by handles, by the admin" based on the original one with the specified parameters.
While I want to try to implement this approach (second). If you have something to say about this, I will be very grateful for the comments.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question