Answers.Body: <p>After much digging, I found the reason why contact images were not appearing.</p>
  
  <p>It was due to a module that had a PHP file with two new lines before the opening PHP tag <code>&lt;?php</code>.</p>
  
  <p>To figure this out, I created a local copy of the website and went through the modules list, enabling them one by one to see at what point the image broke. </p>
  
  <p>Once I'd found which one broke the image, it wasn't hard to go through the files, searching for the whitespace.</p>
  
  <p>Removed the two new lines before the tag and the image instantly worked.</p>
  
  <p>Hopefully this will come to some use if anyone has a dodgy contact image!</p>
  
  <p>On a side note, this also fixed the Mosaico problem I was having - <a href="https://civicrm.stackexchange.com/questions/30856/failed-to-locate-mosaico-graphics-driver">Failed to locate Mosaico graphics driver</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-22T06:37:45.517Z
Answers.Text: Thanks for your solution Jade. My 'rogue' was a custom module my dev had created. One empty line above the opening php tag as per your guidance.
Answers.UserDisplayName: Davy Ivins
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-01T08:02:51.970Z
Answers.LastActivityDate: 2019-07-01T08:02:51.970Z
Answers.UserDisplayName: Jade
Body: <p>I have a problem in CiviCRM when I try to add a contact image into a contact record.</p>
  
  <p>I'm using Drupal 7, CiviCRM 5.13.4 and PHP 7.1.</p>
  
  <p>From what I can make out, something is adding in whitespace to the images that I try and upload which naturally shows the image as being broken.</p>
  
  <p>When I look at the image in the file system, the image is fine there but if I go into the source code of where the image is in a contact record, the image downloads and when I open it, the top line is blank (whitespace).</p>
  
  <p>I have seen this on several sites but can't seem to find an answer anywhere so it would be good to know any possible reasons for this to happen so the fix can be applied to several sites.</p>
  
  <p>I am wondering if it is a rogue module or something similar that is causing the problems. I thought it may be the theme which I disabled to test but the issue remained so that got ruled out.</p>
  
  <p>Any advice would be greatly appreciated!</p>
  
Tags: <drupal><contacts><contact-image>
Title: Civi adds whitespace into contact images
ThreadText: # Civi adds whitespace into contact images
  
  (Asked by: username_0 on 2019-06-10)
  
  I have a problem in CiviCRM when I try to add a contact image into a contact record.
  
  I'm using Drupal 7, CiviCRM 5.13.4 and PHP 7.1.
  
  From what I can make out, something is adding in whitespace to the images that I try and upload which naturally shows the image as being broken.
  
  When I look at the image in the file system, the image is fine there but if I go into the source code of where the image is in a contact record, the image downloads and when I open it, the top line is blank (whitespace).
  
  I have seen this on several sites but can't seem to find an answer anywhere so it would be good to know any possible reasons for this to happen so the fix can be applied to several sites.
  
  I am wondering if it is a rogue module or something similar that is causing the problems. I thought it may be the theme which I disabled to test but the issue remained so that got ruled out.
  
  Any advice would be greatly appreciated!
  
  **Tags:** drupal, contacts, contact-image
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-07-01. Score: 3 | Accepted answer
  
  After much digging, I found the reason why contact images were not appearing.
  
  It was due to a module that had a PHP file with two new lines before the opening PHP tag `<?php`.
  
  To figure this out, I created a local copy of the website and went through the modules list, enabling them one by one to see at what point the image broke.
  
  Once I'd found which one broke the image, it wasn't hard to go through the files, searching for the whitespace.
  
  Removed the two new lines before the tag and the image instantly worked.
  
  Hopefully this will come to some use if anyone has a dodgy contact image!
  
  On a side note, this also fixed the Mosaico problem I was having - [Failed to locate Mosaico graphics driver](https://civicrm.stackexchange.com/questions/30856/failed-to-locate-mosaico-graphics-driver)
  
  > **Comments:**
  > **username_1**: Thanks for your solution username_0. My 'rogue' was a custom module my dev had created. One empty line above the opening php tag as per your guidance.  
  
  ---
  
  