As you will know, when deleting an entry with images, the images aren't deleted from the server. This is one aspect of Expression Engine that I really do not care for: The inexorable build up of redundant files in the system, with- as far as I can tell- absolutely no way of knowing which images are assigned to a channel entry. (Wouldn't it be nice if there were a little display next to each file on the file manager screen telling you which files were assigned to entries..). Here is a post from 2011 with people bemoaning the same issue, and a (great!) feature request which is now a dead link, so presumably met a dead end.

So how do others deal with this problem? How can I keep my image directory clean? and since I have NEVER, in all the sites I have built with EE, had a situation where one image needs to be re-used for more than one entry, I would MUCH prefer a method of locking images permanently to whatever entry they are assigned to. Is this beyond the bounds of Expression Engine?

1 Answer 1


Images attached to entries via a File field in ExpressionEngine aren't treated as relationships (unlike, say, Assets fields). They simply hold a text value like so:


It's not the most robust approach, but it's simple and low-overhead. But it also makes deleting images associated with an entry (but only if they're not in use in other entries) much trickier. Doable, but a pain.

You'd have to write an extension which taps into the delete_entries_loop hook to:

  1. Find all File fields in that entry
  2. Search all other File fields in the database for that matching value
  3. If no matching values are found, parse the value of that file field to locate the image in the database
  4. Delete it (from the database and on-disk) using the File library

However, while you may feel that the use case of multiple entries using a single image file is a rare one, I actually see this all the time. On the flip side, to me, a site which frequently deletes entries (and thus would have a build-up of unused images) is something that is incredibly rare.

So, use cases are in the eye of the beholder. Personally I don't see this feature making it's way into EE myself, but you could always file a feature request by emailing [email protected].

  • +1 for seeing single images in multiple entries. The bigger your site, the greater your entropy!
    – jrothafer
    Oct 24, 2015 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.