Would there be any ability via a browser of some sort to delete images uploaded? Some sort of management utility to perform this would be useful if there are user limits imposed on the total size of images uploaded. Also, to delete unreferenced files to save hard disk space.

Comments

eugenmayer’s picture

Well all it needs is a submit handler for the node, which scans the inline images and compares it to the databes, if one is missing settings $file->delete. All the rest will be done automatically. So thats pretty easy :)

twod’s picture

What if two or more nodes reference the same image?
I haven't looked at the module's schema, does it keep track of which images are references by which nodes so it can do a quick lookup to determine if the "reference count" is 0, and if not, keep the image? Or would it need to scan the contents of all the nodes to know this?

eugenmayer’s picture

Yes the relation is created - but only "add". That means, that if you delete an image in a content (inline, not the whole content) the relation is not updated. And thats what iam talking about here, using the nodeapi and checking (using the same regexp as the filter doees) what inline-ids are still preset, updating the relation-table. Then running a "cleanup" method which would delete any files which have a ref-count of 0.

rnexussix’s picture

So, is there a way to delete an uploaded image ?

eugenmayer’s picture

There is a way, but it is not yet implemented

David Frohmader’s picture

It seems to me that this is a very important feature. Here is what I myself have done badly.
1) Uploaded the same image twice by mistake.
2) Uploaded a number of images that had been sized incorrectly in Photoshop. Now the correct sized photos must also be uploaded.
3) In the near future poor quality pictures will be replaced with better ones. It would be best to totally remove the poor pictures.
So is there a manual way to do this? Can they just be deleted from the folder where they are located on the web server?

eugenmayer’s picture

Well what you want is a image-management for the uploaded images. With the upcoming views integration in 2.3 you can use views bulk operations to delete images as an administration task.

There will also be a algorythm which will detect, if an image is no longer used on any node and will get deleted. This is something more complex you might think about. Especially when it comes to revisions, you will actually never delete any image at all, because they are used in revisions "back then". So automatic deletion is something for non revisioned-sites or for rather accident uploads as in your case.

If you want to remove images manually, just open the node in edit mode, press the "disable richtext editor" button. Then look for the [[wysiwyg_imageupload:ID:]] tag. you need the ID. then go to the wysiwyg_imageupload_entities table and remove that id. To make it clea, also delete it from wysiwyg_imageupload_entity_revision. And if you want to make it completly clean, you need to delete the fid out of the files table. I guess you just use a join for that

delete from wysiwyg_imageupload_entities as wui LEFT JOIN wysiwyg_imageupload_entity_revision as wuir ON wui.iid=wuir.iid LEFT JOIN files ON wui.fid=files.fid WHERE iid=<insert iid>

Untested query! Backup your database.

pepe roni’s picture

Why did you invent the wheel again? Filefield (ok, CCK is needed, but which site does not have it, eh?) has had the same problem and solved it. Why not use a filefield mechanism to handle images?

I have not found a way to reuse an image with your module, so the usage count can only be 0 or 1 (without revisions), not more. So if you delete the image in the editor, mark it as "to be deleted" and delete it on node save. What's the problem? If node revision is set the count could be higher, so reduce the image count on image delete and update this counter on node save. If the counter is 0, delete the image (filefield already has all these features).

The user interface of this module is very simple and supports what most of my users want to do: "I need an image -> I upload it from my computer. I need the image again -> I upload it again. I don't care about uploading an image twice or more often. I don't care of the housekeeping of the site". But as the users don't care of housekeeping, your module should do and that the most contra for your module.

If you need an image browser, there are many available, mostly more complex ones, and users (except for drupal freaks) do not understand why to reuse an image. So more functional modules gain less acceptance by the users.

You have kept it as simple as possible, and that's why I really like your module. Danke!

eugenmayer’s picture

You are free to help implementing it, iam glad for every patch :)

pepe roni’s picture

Component: User interface » Miscellaneous
Category: feature » bug

If I was a module developer, I would really like to help you ;)

I also changed the category and component, because it is not merely a feature request, it is a real bug that this module doesn't do its housekeeping, and it is not a matter of user interface (thats really good in fact) but of the underlying system.

Indeed, for media resources the filefield module has been designed and this should be used then. Especially if you think of "everything is a field" in D7! You do not even need the imagefield module as this only adds a user interface for images. Why not add a hidden field to the node, with multiple values, and you store the uploaded images in this field? The rest can do the filefiield module. Or you add a visible imagefield to the node and the users can even reuse images themthelves (the filefield module is able to reuse resurces).

Your user interface together with the filefield infrastructure: that would be great!

eugenmayer’s picture

Category: bug » feature

That is and stays a feature request, please dont change statuses. There is hardly no implementation of this in other module for this kind of house-keeping.

Filefield is not an option at all. Otherwise we would need to remove comment support, as comments have no filefields. Same for blocks, webforms, panel-inlnies etc.

The implementation of this is not hard, but not critical for me. So it will take some time i can invest time on this. If this is critical for you, i guess you will have to put your time into this.

eugenmayer’s picture

Status: Active » Fixed

Thats now implemented and will be removed in 2.4.

If you delete a node, all WUI entries will be delete. The corresponding files will be delete if no other module gives a veto using the new hook_wysiwyg_imageupload_veto_file_deletion hook. WUI implements this hook and vetos if this fid (files) is used in a different node ( inserted using the browser).

so i guess we are finally done with that one

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

traceelements’s picture

Status: Closed (fixed) » Needs work

I'm having a problem with this feature. When I add an image from the image browser to two different nodes, and then delete one of the nodes, the image appears to stay in the other (undeleted) node like it's supposed to. However, when I click edit for the undeleted node, the image link is broken, and the browser says it can't find the image. Is there a way for me to turn off automatic image deletion?

eugenmayer’s picture

Status: Needs work » Closed (fixed)

reopen a new issue and explain what you have experienced. And no, there is no way to disable this