Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-20326

Contact images url storage in the database

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 4.7.16, 4.6.26
    • Fix Version/s: None
    • Component/s: Core CiviCRM
    • Labels:
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      User and Admin Doc
    • Funding Source:
      Needs Funding
    • Verified?:
      No

      Description

      The contact image files are stored as a full url in the database (civicrm_contact.image_url), ie. https://<website_domain>/civicrm/contact/imagefile?photo=image.png.

      This presents issues:

      1. when the website's URL is changed (ie. moved to a new domain, or moved from a subdomain to the www domain),
      2. in a CiviCRM multisite environment, the images uploaded in one domain are not visible in other domains unless the user also has access AND is logged in the domain where that picture was uploaded.

      Note that 1 is not resolved by putting a redirect in place since the user needs to be logged in the domain hosting the images for the link to work. So for the redirect to work you would need to be logged in the website at the old URL as well as the current website.

      I see 2 solutions to this issue:

      1. adopt the same methodology as for the civicrm_file table and just store the file name in the image_url field (so it really is image_file rather than image_url now). The rest of the URL is generated on display.
      2. replace the https://<website_domain>/ with the new [cms.root] token so the url is saved as [cms.root]/civicrm/contact/imagefile?photo=image.png in the database. Token expansion is done on display.

      Note: tested on 4.7, even if the imageUploadUrl indicate [cms.root] the image_url is still saved in the database as the full URL. However changing to the [cms.root] syntax in the database corrected expands to the full URL on display. So solution 2 is halfway done.

      Impact on both of the above solutions for multisite is that the image upload folder must be the same across sites so that one site can access images uploaded by another. We need to update the multisite documentation for that as nothing is specified now.

      Note: are there use cases where the above is not desirable? Ie. one site could see images/files uploaded from the other sites that they are not supposed to see?

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                nganivet Nicolas Ganivet
              • Votes:
                0 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated: