From 40bfc1c523056cdf80b036b242d728e3952037a2 Mon Sep 17 00:00:00 2001
From: Oliver Davies <oliver@oliverdavies.co.uk>
Date: Tue, 24 Feb 2015 15:17:22 +0000
Subject: [PATCH] =?UTF-8?q?Return=20NULL=20if=20the=20user=20hasn=E2=80=99?=
 =?UTF-8?q?t=20uploaded=20a=20picture?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 template.php | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/template.php b/template.php
index f6eee489..51612883 100644
--- a/template.php
+++ b/template.php
@@ -89,15 +89,20 @@ function bluecheese_election_candidate_ballot_item($variables) {
   $candidate = $variables['candidate'];
   $account = user_load($candidate->uid);
 
-  $picture = theme('image_style', array(
-    'style_name' => 'candidate_thumbnail',
-    'path' => $candidate->field_election_picture[LANGUAGE_NONE][0]['uri'],
-    'alt' => t('@user’s picture', array('@user' => format_username($account))),
-    'attributes' => array(
-      'title' => t('View user picture'),
-      'class' => array('candidate-picture'),
-    ),
-  ));
+  if (!empty($candidate->field_election_picture)) {
+    $picture = theme('image_style', array(
+      'style_name' => 'candidate_thumbnail',
+      'path' => $candidate->field_election_picture[LANGUAGE_NONE][0]['uri'],
+      'alt' => t('@user’s picture', array('@user' => format_username($account))),
+      'attributes' => array(
+        'title' => t('View user picture'),
+        'class' => array('candidate-picture'),
+      ),
+    ));
+  }
+  else {
+    $picture = NULL;
+  }
 
   $full_name = theme('election_candidate_full_name', array('candidate' => $candidate));
   $link = l($picture . $full_name, election_candidate_uri_path($candidate), array('html' => TRUE));
-- 
GitLab