Just upgraded to 4.6.0 and now I see that the CiviCRM Contact Image field in Drupal views now uses the views image handler! Awesome! Prior to 4.6 it was just a string containing a URL to the image. Thanks to @Shawn Duncan for his efforts and contribution.

However, I can't get it to work. The image URL it produces gives a 404

Example URL that returns 404:


But the actual working URL to the file is:


So it's inserting an extra example.com after the /files/ and it's using this /contact/imagefile%3Fphoto%3D instead of the actual path to my custom uploads.


Using Drupal image presets is broken in 4.6 since at least 4.6.6; if you select an image style in Views, it mangles the URL to something like

<img typeof="foaf:Image" src="http://styles/medium/http/example.org/civicrm/contact/imagefile?photo=bsglo‌​go_49524b829beb4448767ee75a42f2dcc0.jpg&amp;itok=dGLXdcig" width="220" height="220" alt="" title="">

Is there a suitable workaround?

  • I have edited my question to include links to the relevant issue tracker page and GitHub pull request.
    – LunkRat
    Apr 8, 2015 at 2:28

1 Answer 1


Your site is affected by CRM-16009 - URL for Contact Image in View incorrectly generating.

That URL should look like this -


rather than this -


The civicrm/contact/imagefile handler permits CiviCRM to provide its permissions checks on whether the image in question should be served up.

Since that code was merged, there's a good chance it worked for someone and this may be fixable in configuration. It looks like the URLs you're getting from Views are confused - possibly by CiviCRM configuration, or by an issue with the views implementation as it currently stands, possibly an incorrect assumption in code about the location of CiviCRM codebase or system files, etc.

  • Serving images from CiviCRM file fields also incurs a substantial performance kick; I recommend not using CiviCRM imagefile fields if you are serving images to the public. You're far better off serving the file directly with no PHP at all OR putting ImageCache + ImageCache External in front of it. Initialising CiviCRM for each image request adds some real delay to the process. Apr 8, 2015 at 3:49
  • See these notes and this forum thread for some notes / performance metrics based on current CiviCRM.org use of the imagefile handler. Apr 8, 2015 at 3:49
  • Thanks @Chris Burgess for the detailed explanation, advice, and links to resources. I agree with you that serving images publicly via CiviCRM is not ideal in terms of performance. However in my use-case it is ideal in terms of simplicity and usability: my view shows the logos of "active sponsors" (organizations with current/active memberships). From a data entry perspective they can just pull up the contact, add the logo, record the membership. The logo then appears in the view automatically. When the membership expires, the views filter removes the logo. When they renew, the logo reappears.
    – LunkRat
    Apr 8, 2015 at 14:26
  • Great to see you're engaging that issue Link. Yep, understood about convenience of the CiviCRM field. To clarify: once set up, using ImageCache External in front of the active sponsor images would give you the same behaviour (the styled image would appear in the view conditional on sponsorship) but you'd have a faster-loading site. Whether it's worth the effort depends on your traffic and resources! Apr 8, 2015 at 20:38
  • 2
    It seems that in 4.6.6 the contact image is completely broken if I choose a Drupal image preset, it outputs: <img typeof="foaf:Image" src="http://styles/medium/http/example.org/civicrm/contact/imagefile?photo=bsglogo_49524b829beb4448767ee75a42f2dcc0.jpg&amp;itok=dGLXdcig" width="220" height="220" alt="" title="">
    – LunkRat
    Aug 7, 2015 at 20: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.