0

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!

1 Answer 1

3

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

1
  • 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.
    – Davy Ivins
    Commented Aug 22, 2021 at 6:37

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.