Skip Navigation

[Escalated to 2nd Tier] Cred Form – Huge amount of deleted images remain in Media Library

This support ticket is created 6 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 0.89 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Tagged: 

This topic contains 14 replies, has 3 voices.

Last updated by Waqar 5 years, 10 months ago.

Assisted by: Nigel.

Author
Posts
#952796

Hello,

I have seen multiple threads about this issue from the past years and I would like to ask if has changed sth.

1) When an imaged is uploaded as repeated image field via a cred form it remains permantly in the media library even if the user "deletes" it via a cred form.
2) If a user makes trials and uploads multiple images via a single image field of a cred form, in order to decide which one he likes more as his profile photo before hiting the submit button all these images are uploaded to the media library
3) WordPress generates 4 new images for each uploaded image so you understand that the amount of the images that will be never used and remain to the server is huge.

Is there any solution about that?

#952802

I understand the concerns.

The exact same issue is happening (and would if WordPress would have Front End Forms) with just WordPress.

Media does not really belong to just one post.

Let's see it from the most simple aspect:
- You create a post no matter of what kind with no matter what kind of media uploaded to it (don't even use Toolset)
- Another user, a little later, creates another post, and wants to add an image he/she finds in the Media Library or even, yourself as original first post author want that image on another post as well.
- Now, the first posts' author deletes the image (from his/her post)
==> All other users posts would now miss an image.

That is why, generally, Media is deleted only in the or with the Media screen in WordPress and related API.

In the case you outline, which is more sophisticated (the user deletes the image BEFORE he/she even publishes the post in a form) is basically the same.

See, in WordPress Backend the same would happen, just, in Toolset Forms you do not see it happen, as it's a Front End Form.

When you want to see an image in your Post (as "preview" in this case) you usually upload it.
Wether in WordPress backend, or in a Forms front end, that image first is uploaded. Then you see it.

In the backend you simply choose another image and/or choose to delete the previously uploaded - but with specific actions targeted to the MEDIA, not the post.

So, this is what happens on the front end as well.
The image is already uploaded, it needs to, to produce the valued "preview" view.

Now, what you can do is for example, apply some custom logic that really deletes the attachment when the form is submitted and some media was removed.
But that involves complex custom code (I can give examples about) and, more than any else, it involves that you need your users, which submit the form, be aware of the fact of if they delete, they may delete for others as well.

What I see from our end that we can improve (but this is problematic due to above details) is that if a Image was never really used, in a form, we as well remove it again.
That means the attachment should first be uploaded as a not public media, then if published with the post we can proceed, if not, we need to remove the stuff from the database.

I can ask the developers to look into this if you agree with this final idea.

#952810

Yes, of course I agree!!! That would be perfect!!!

#952814

OK, I'll see what we can do.

Meanwhile if you have no further questions we can close this here, as the changes, if applied - would be communicated thru the chnagelog or blog post.

#952837

I assume that it will be needed some time for the the developers to do sth like that and a new blog post been published.

Untill then could you please help me with the first solution? How I could delete the attachment when the form is submitted if some media was removed from it? I believe that there will be no issues with media used from other users as the users do not have access to the media library. They can only use the site from the frontend and upload photos only for their own posts. So everything will be ok.

Also I would suggest for the developers if it would be possible each post type or each cred form to have a boolean field where the admin would check if the media that are uploaded as attachments should be available for the rest users and for the rest post types. Only in the condition that admin checks no:

1) the media that are not used for the post or
2) if the post is been deleted

the media would also been deleted from the database. This way no user would delete a media that may be used somewhere else

#954317

1. The easiest is disable AJAX Uploads and hence, the image wont be uploaded aforehead:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_file_upload_disable_progress_bar
Then, the user can upload the image but he won't see any preview or similar
The database is not cluttered

2. The other approach would be to flag the image (attachment) with some unique data on upload and then delete later with a query targeting those flagged attachments.

The problem is, I saw nothing that Toolset Forms uses to actually track those attachments, hence I cannot craft any code that deletes them.

I?ll add this idea to the internal issue trailer.

#954350

Hello Beda,

I tried the first solution but it is not working. Progressbar is disabled now but the image is not uploaded. I can see the name of the file in the cred form but that file is never uploaded to the server.

But even if it worked it would be a bad user experience, Also I cannot track the images that the user will delete later through the cred edit form. The only way to avoid a huge amount of unused photos would be If I we fixed the bug, allowed the user to upload the photo without the progress bar and also do not allow the edition of any photo that has been uploaded. But this would be a very bad user experience, don't you think? The users will not be able to change their profiles' and their services' photos.

I think that the big issue that does not allow us to track the photos that have been deleted is that after the deletion through the cred form, the photos still remain attached to the post. Could you please ask the developers if there is a way to detach the photos after they have been deleted or when they are uploaded but finally not used for the post? Then we would just delete the detached photos from the server.

#954389

Are you sure you have the latest Toolset Forms?
There was a BUG exactly like that:
https://toolset.com/errata/disabling-ajax-upload-in-cred-forms-stops-forms-from-uploading-data-altogether/
I tested the last version locally and it works.

The attachments do not remain on the post.
They are exactly removed from this connection, but not deleted.
The attachments are uploaded wether with or without AJAX upload bar.

We do not delete, but disconnect the attachment

As explained earlier unfortunately the only we could do here is flagging the attachment and I did file the request.

I suggest for the issue with the progress bar, to open a new ticket.
I can split it for you, if you confirm that this still happens with the native theme TwentySeventeen or similar and just Toolset.
Otherwise it may be a compatibility issue that we can as well analyze in a new ticket

#954426
Image From Media Library.jpg

I have now the latest version of all toolset plugins and switched from astra to twentyseventeen theme but still the image does not upload when the progressbar is disabled. I will try to a new installation and if the problem persists I will open a new ticket for that.

Although the image may be deleted from the cred form, if I visit the media library I can see that it is still attached to the post (screenshot). So when I choose from the dropdown menu to view all the unattached images in order to delete them, it will not appear there. Wouldn't be simpler and easier just to detach the image from the post as it is built in wp behaviour instead of finding a new way to flag it as deleted?

#955386

Yes, but after you post this post you won't see that image any more attached.

I agree, the developers will find the best way to solve this and I think you are right to use WordPress available technology and n to reinvent the wheel.

However, I cannot expedite this more than possible.

I will if you want update you here on the progress or you can await the news related to by blog or change logs.

Please let me know about the other issue if you need help there or I should go ahead and split a ticket for you.

#955517

After I post this post the image will be attached to it. I mean to be disconnected-unattached from the post only when the user deletes it through a cred form. For now it still remains attached as you can see from the screenshot although I have deleted it through the cred form. Yes, I am sure that the developers will find the best way to solve it.

I will try to a new wordpress installation for the other issue and if the problem appears again, I will open a new ticket for that, as it is a different issue.

If you could update me here when you have news it would be perfect, as I will get notified instantly with email. Thank you for your interest and for the good support as always!!!

#956342

I will set this ticket in a state of "Fixed in next release" in this case, please don't let you confuse by that - this will not happen in the next release, I am afraid.
I will update you once I have news related to this request.

#1168647

I am closing this ticket because we changed the way we gather feature requests and this issue depends on one (which we are working on, currently).

Thank you for understanding.

#1171735

Hello Beda,

Could you please inform me about the feature request that the developers are working on? Will be possible in the future for the images that are deleted from the frontend, to be be deleted from the media library too or be detached from the post?

Thank you!

#1172882

Hi there,

Beda is off for the next couple of days, but I'll be happy to follow up here.

Our development team is revamping front-end uploads through forms, to make them less dependant on the custom solution and closer to how WordPress native media library works.

Unfortunately, at this time we don't have any specifics of the possible outcome, but we will keep you updated with the progress, through this thread.

Thank you for your patience.

regards,
Waqar