Answers.Body: <p>The image_URL returned by the API is the image that is attached to the CiviCRM contact, not to the Drupal user. You can upload an image of a contact by selecting edit and upload a file with "Browse/Upload Image" in the first section. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-12T16:23:18.870Z
Answers.LastActivityDate: 2017-07-12T16:23:18.870Z
Answers.UserDisplayName: Kainuk - CiviCooP
Answers.Body: <p>This works (tested after attaching an image to a contact on the demo site):</p>
  
  <pre><code>CRM.api3('Contact', 'get', {
    "sequential": 1,
    "return": ["image_URL","first_name","last_name","email"],
    "image_URL": {"IS NOT NULL":1}
  }).done(function(result) {
    // Debug first image URL retrieved:
    console.log(result.values[0].image_URL);
  })
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-16T10:11:05.540Z
Answers.LastActivityDate: 2018-10-16T10:11:05.540Z
Answers.UserDisplayName: Chris Burgess
Answers.Body: <p>Following API call returned image_url</p>
  
  <p><code>$result = civicrm_api3('Contact', 'get', array(
    'return' =&gt; "image_URL",
    'id' =&gt; CONTACT_ID,
  ));</code></p>
  
  <p>Response looks like this:</p>
  
  <p><code>{
      "is_error": 0,
      "version": 3,
      "count": 1,
      "id": xxxxxx,
      "values": [
          {
              "contact_id": "xxxxxx",
              "image_URL": "xxxxxxxxxxxxxxxxxxxxxx.com/civicrm/contact/imagefile?photo=Img1_ca0063c865d7fe65019be27dd071258c.png",
              "id": "xxxxxx"
          }
      ]
  }</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-16T18:50:15.310Z
Answers.LastActivityDate: 2018-10-16T18:50:15.310Z
Answers.UserDisplayName: Hassan Farooq
Body: <p>I'm trying to retrieve contact with the below api call</p>
  
  <pre><code>CRM.api3('Contact', 'get', {
    "return": ["image_URL","first_name","last_name"]
  }).done(function(result) {
    // do something
  });
  </code></pre>
  
  <p>but my image url is always empty despite having an image on my contacts profile. This is what the response looks like</p>
  
  <pre><code>"is_error": 0,
  "version": 3,
  "count": 5,
  "values": {
      "1": {
          "contact_id": "1",
          "image_URL": "",
          "first_name": "",
          "last_name": "",
          "contact_is_deleted": "0",
          "id": "1"
      },
      "2": {
          "contact_id": "2",
          "image_URL": "",
          "first_name": "AdminJoshua",
          "last_name": "AdminAroke",
          "contact_is_deleted": "0",
          "id": "2"
      },
      "3": {
          "contact_id": "3",
          "image_URL": "",
          "first_name": "Joshua",
          "last_name": "Aroke",
          "contact_is_deleted": "0",
          "id": "3"
      },
      "4": {
          "contact_id": "4",
          "image_URL": "",
          "first_name": "Oluwajuwon",
          "last_name": "Aroke",
          "contact_is_deleted": "0",
          "id": "4"
      },
      "5": {
          "contact_id": "5",
          "image_URL": "",
          "first_name": "Ogirima",
          "last_name": "Aroke",
          "contact_is_deleted": "0",
          "id": "5"
      }
  }
  }
  </code></pre>
  
  <p>I have been trying to put this to work. I'm using drupal 7 and I have profile image set on my contact. Please, let me know what to do right</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-13T07:39:33.837Z
Comments.Text: Hi, Olyjosh, just tried this on the demo CiviCRM (4.7.17)  instance and it works fine. I use the API explorer (See http://dmaster.demo.civicrm.org/civicrm/api#explorer). What is your version of CiviCRM? Does image_URL work when you call the API with the explorer or with Drush?
Comments.UserDisplayName: Kainuk - CiviCooP
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-13T23:10:38.097Z
Comments.Text: My version of CiviCRM is CiviCRM 4.7.16.
  The above json print is from the api explorer
Comments.UserDisplayName: olyjosh
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-14T09:04:35.657Z
Comments.Text: Try to reproduce the situation on the demo instance. If it works, search for a difference on your local installation.
Comments.UserDisplayName: Kainuk - CiviCooP
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-14T09:38:49.627Z
Comments.Text: I just edited the demo instance and uploaded an image to the instance here [http://dmaster.demo.civicrm.org/user/2/edit](http://dmaster.demo.civicrm.org/user/2/edit) and I use the api explorer [http://dmaster.demo.civicrm.org/civicrm/api#explorer](http://dmaster.demo.civicrm.org/civicrm/api#explorer)  to query drush like this   
  
  drush cvapi Contact.get sequential=1 id=202. 
  
  **Behold, It's the same thing, the image element is empty too.**
Comments.UserDisplayName: olyjosh
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-14T09:58:15.317Z
Comments.Text: The image_URL returned by the API is the image that is attached to the CiviCRM contact, not to the drupal user. You can upload an image of a contact by selecting edit and upload a file with "Browse/Upload Image" in the first section.
Comments.UserDisplayName: Kainuk - CiviCooP
Tags: <drupal><api><contact-image>
Title: How to retrieve contact image URL in CiviCRM with the API
ThreadText: # How to retrieve contact image URL in CiviCRM with the API
  
  (Asked by: username_0 on 2017-02-13)
  
  I'm trying to retrieve contact with the below api call
  CRM.api3('Contact', 'get', {
    "return": ["image_URL","first_name","last_name"]
  }).done(function(result) {
    // do something
  });
  
  but my image url is always empty despite having an image on my contacts profile. This is what the response looks like
  "is_error": 0,
  "version": 3,
  "count": 5,
  "values": {
      "1": {
          "contact_id": "1",
          "image_URL": "",
          "first_name": "",
          "last_name": "",
          "contact_is_deleted": "0",
          "id": "1"
      },
      "2": {
          "contact_id": "2",
          "image_URL": "",
          "first_name": "AdminJoshua",
          "last_name": "AdminAroke",
          "contact_is_deleted": "0",
          "id": "2"
      },
      "3": {
          "contact_id": "3",
          "image_URL": "",
          "first_name": "Joshua",
          "last_name": "Aroke",
          "contact_is_deleted": "0",
          "id": "3"
      },
      "4": {
          "contact_id": "4",
          "image_URL": "",
          "first_name": "Oluwajuwon",
          "last_name": "Aroke",
          "contact_is_deleted": "0",
          "id": "4"
      },
      "5": {
          "contact_id": "5",
          "image_URL": "",
          "first_name": "Ogirima",
          "last_name": "Aroke",
          "contact_is_deleted": "0",
          "id": "5"
      }
  }
  }
  
  I have been trying to put this to work. I'm using drupal 7 and I have profile image set on my contact. Please, let me know what to do right
  
  **Tags:** drupal, api, contact-image
  
  > **Comments:**
  > **username_1**: Hi, Olyjosh, just tried this on the demo CiviCRM (4.7.17)  instance and it works fine. I use the API explorer (See http://dmaster.demo.civicrm.org/civicrm/api#explorer). What is your version of CiviCRM? Does image_URL work when you call the API with the explorer or with Drush?  
  > **username_0**: My version of CiviCRM is CiviCRM 4.7.16. The above json print is from the api explorer  
  > **username_1**: Try to reproduce the situation on the demo instance. If it works, search for a difference on your local installation.  
  > **username_0**: I just edited the demo instance and uploaded an image to the instance here [http://dmaster.demo.civicrm.org/user/2/edit](http://dmaster.demo.civicrm.org/user/2/edit) and I use the api explorer [http://dmaster.demo.civicrm.org/civicrm/api#explorer](http://dmaster.demo.civicrm.org/civicrm/api#explorer)  to query drush like this     drush cvapi Contact.get sequential=1 id=202.   **Behold, It's the same thing, the image element is empty too.**  
  > **username_1**: The image_URL returned by the API is the image that is attached to the CiviCRM contact, not to the drupal user. You can upload an image of a contact by selecting edit and upload a file with "Browse/Upload Image" in the first section.  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2017-07-12. Score: 1 | Accepted answer
  
  The image\_URL returned by the API is the image that is attached to the CiviCRM contact, not to the Drupal user. You can upload an image of a contact by selecting edit and upload a file with "Browse/Upload Image" in the first section.
  
  
  ---
  
  ### Answer by username_2 on 2018-10-16. Score: 0
  
  This works (tested after attaching an image to a contact on the demo site):
  CRM.api3('Contact', 'get', {
    "sequential": 1,
    "return": ["image_URL","first_name","last_name","email"],
    "image_URL": {"IS NOT NULL":1}
  }).done(function(result) {
    // Debug first image URL retrieved:
    console.log(result.values[0].image_URL);
  })
  
  
  ---
  
  ### Answer by username_3 on 2018-10-16. Score: 0
  
  Following API call returned image\_url
  
  `$result = civicrm_api3('Contact', 'get', array(
  'return' => "image_URL",
  'id' => CONTACT_ID,
  ));`
  
  Response looks like this:
  
  `{
  "is_error": 0,
  "version": 3,
  "count": 1,
  "id": xxxxxx,
  "values": [
  {
  "contact_id": "xxxxxx",
  "image_URL": "xxxxxxxxxxxxxxxxxxxxxx.com/civicrm/contact/imagefile?photo=Img1_ca0063c865d7fe65019be27dd071258c.png",
  "id": "xxxxxx"
  }
  ]
  }`
  
  
  ---
  
  