I'm wondering if anyone else has come up with a good way to manage their custom files (where documents and images which are attachments to contact records are stored.)

We have a fair amount of files in this folder. In addition, some of the contact images have been 'deleted' in Civi (i.e. mistakenly uploaded and replaced with a new image or updated with a newer image.)

Any way to cull through the files and remove files no longer in use? Or to separate contact record images from pdfs attached to activity records?

1 Answer 1


Might justify developing a script or extension?

  • The column uri in the database table civicrm_file seems to refer to these.
    • The table civicrm_entity_file then links civicrm_file records to other existing entities.
  • The column image_URL in the table civicrm_contact, on my transplanted legacy installation at least:
    • in some cases contains absolute URLs that also reference files in this folder,
    • and in others contains URLs to civicrm/contact/imagefile with a photo parameter that is a filename in this folder.

So you may be able to identify unreferenced files that way, although I won't guarantee that files in that folder can't be referenced from elsewhere too.

  • Thanks for the breakdown of where the files may be referenced from. Seems like I have a fair bit of manual work to clean up this folder. Would be nice to figure out how to manage this folder - I'm sure that means writing an extension and I'm not sure I'd know where begin but I'll keep some notes on what might be helpful.
    – RayWright
    Mar 30, 2018 at 22:51
  • Note that files, which are uploaded in a text field with a wysiwyg editor, are not listed in the mentioned tables. Only their uri is saved as part of the html of this text field. So it's not that easy to find all usage. Dec 17, 2019 at 8:54

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.