Proposal: add `civicrm_contact.image_file_id` column
Problem
Handling of contact images is nonstandard and difficult to work with.
Current Behavior
Uploading a contact image will:
- Store the file in (by default)
civicrm/custom
. - Update the
civicrm_contact.image_URL
column with a link to an ajax callback for accessing the image. - Not create a record in the
civicrm_file
table. - Not create a record in the
civicrm_entity_file
table.
Deleting a contact image in the UI will:
- Not delete the file.
- Set
civicrm_contact.image_URL
tonull
.
Proposed New Behavior
Add a civicrm_contact.image_file_id
column, FK to civicrm_file.id
.
Uploading a contact image will:
- Store the file as before.
- Update the
civicrm_contact.image_URL
column as before. - Create a record in the
civicrm_file
table. - Store the file id in the
civicrm_contact.image_file_id
column -
Undecided: should an entry also be created in
civicrm_entity_file
? See #2760 (closed)
Deleting a contact image in the UI will:
- Delete the file if an id is present in
image_file_id
column. - Set
civicrm_contact.image_URL
andcivicrm_contact.image_file_id
tonull
.