-
Notifications
You must be signed in to change notification settings - Fork 76
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
Delete unused images #2
Comments
Hi. It's needed this. I'm detecting some issues: 1.- When I create a new item and I upload a image, automatically the file is upload to "[defined path]" and "[defined path]/thumbnails" folder with a hash. And I have no original image defined in the config. 2.- If I crop the image and continue, the cropped image is uploaded automatically to "[defined path]/cropped" and "[defined path]/cropped/thumbnails" folder with a hash, wich is different to full image hash. 3.- If I flush the new item, all it's ok. The files are there. But in the database I only have the cropped filename with the step 2 hash. 4.- If I cancel the new item, the images have been uploaded anyway. Then, I can't imagine how to handle the images deletion. My knowledge of symfony is limited, but I'm trying to handle this and I'm frustrated. I hope you will deal with this soon. I don't know how to resolve it :-( |
Hi @Tersoal I have some thoughts about this issue. First, you can save original file name in another field if you want to delete it when your entity is removed (be careful, you will no longer see this image in "already uploaded" images selection). To do this, you can pass a parameter to your field : https://github.com/comur/ComurImageBundle#saveoriginal-optional Then in your entity you need to use http://doctrine-orm.readthedocs.org/en/latest/reference/events.html#preremove function to delete images uploaded / cropped by this entity. Tell me if you are able to achieve that. |
Thanks! Let me see... |
Well, it does not work. I have defined my image field with 'saveOriginal' => false (or you can delete this as it's by default). The image file is upload by ajax to the server anyway, just when the image is selected to upload. Preremove lyfecycle callback does not work because the defined field isn't a file, but string instead. I'm updating my form, entity and controller to delete files. I'll put here, and it should be included in the doc for reference to new users. |
Send me your code and i will show you how to do it. I have to include a real example in the project |
I'll put here. Is up to you how include it in the docs. I see other problems that I have to confirm in my tests. |
Hi. I have resolved the old image files deletion with a service. The problem is that it must be done for all entities that have a comur image field, and I have tried to do in the bundle, but I don't know how identify the image fields in classmetada. My knowledge of symfony is not sufficient.
|
Hi, Thanks for this great job, I will take some time to check it. |
Have to find a way to delete images when they are not used anymore.
2 possibilities:
Any way, we have to create a service to get all image types (cropped, thumbs) related to an image.
The text was updated successfully, but these errors were encountered: