How to handle images in a CMS where people can edit their own html
We have a CMS where people can upload images. We do not currently offer a delete feature, but it would be nice to offer one. The problem with suggesting the delete function is that people can delete an image they don't need, but that same image could be used in another article. Since people select images using a WYSIWYG browser editor, we can't keep track of which image is being used very easily, I guess.
Does anyone have a good solution on how to enable uninstall without breaking other articles?
a source to share
If you have saved the location of the image in the database and users selected from the generated database list, you can add a link count to the image record. Enlarge it when the image is added to the page, shrink it when it is removed.
Then, in the image management pages, only delete is allowed if the link count is 0.
Although, if users can edit their own HTML, there is nothing you can do to stop them (other than education) from directly linking to images.
a source to share
A little analysis of the post data could provide some image URIs that you could use to change the link count (this will work for direct changes too)?
Also like reference counting, if you don't, you can call through the loaded media on a per-user basis - that way if they delete something they don't think they need, it isn't going to kill the other user running?
None of them are particularly elegant ... but not a problem either: P.
While it really depends on how you implemented your CMS solution, it's probably a good idea if you keep track of which articles are linking to your images. Then when someone removes the image from their article, you know that you are only deleting the image file itself if you have null links left.
a source to share