V
V
VesX2014-06-22 17:24:59
OOP
VesX, 2014-06-22 17:24:59

How to properly handle form data?

The Symfony 2 framework is used.
There are entities an album, a photo.
Also, the album entity has a "cover" field.
Albums are created based on the data sent through the form. There are also transmitted photos that relate to this album and the cover.
Albums have folders where his photos and cover are stored.
I want to reduce the size of the photos and cover when uploading and put it in the album folder.
Moreover, the parameters of this reduction (required height, width) are different for the photo and the cover.
There is a service for manipulating images. (Gregwar/ImageBundle)
At this stage, a service has been created that, depending on the type of image (photo or cover, the type is specified explicitly), takes the desired width - height from the config and using Gregwar / ImageBundle resizes the image.
Regarding relocation:
After submitting the form, the image of the UploadedFile class is moved to a temporary folder, it is given a unique name and its own extension. Further, the path to the moved image is passed to the service that will reduce it. After that, based on this path, an object of the Image class will be created and passed to the Album entity, which will move it to its folder in its setter.
It seems to me that this solution is far from ideal. I would like a better option.
Question: How should this whole process be organized?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Solovyov, 2014-06-22
@pavel_salauyou

install nginx and nginx image filter module and don't worry

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question