When I log in, or load a user resource, and the site has user account pictures enabled, this is what I get for the user picture:

<picture>
<fid>13</fid>
<uid>7</uid>
<filename>picture-7-1366818948.jpg</filename>
<uri>public://pictures/picture-7-1366818948.jpg</uri>
<filemime>image/jpeg</filemime>
<filesize>46528</filesize>
<status>1</status>
<timestamp>1366818948</timestamp>
</picture>

There is no way of getting a URL for the picture from the above. The best thing there is the URI, public://pictures/picture-7-1366818948.jpg, but that requires knowledge of what the 'public://' resource corresponds to, which is a piece of site configuration data -- not something a consumer of the service can assume.

CommentFileSizeAuthor
#1 1978844.services.user-picture-url.patch508 bytesjoachim

Comments

joachim’s picture

Status: Active » Needs review
StatusFileSize
new508 bytes

Here's a simple patch that adds this in if user pictures are enabled.

kylebrowning’s picture

Status: Needs review » Needs work

Because this changes response and what people are expecting, it must use versions built into services.

Take a look at services.versions.api.php in services/docs

Or this code :P

yeah because if you change the user resource directly, peoples clients will break when they update Services.

As an example, this is in the user resource and lets admins choose the version they wish to use for the logout method.

<?php
/**
 *  Update the current user logout callback to the new callback with a better return value.
 */
function _user_resource_logout_update_1_1() {
  $new_set = array(
    'callback' => '_user_resource_logout_1_1',
  );
  return $new_set;
}

/**
 * Logs out the currently logged in user and returns the new user object.
 */
function _user_resource_logout_1_1() {
  global $user;

  if (!$user->uid) {
    // User is not logged in
    return services_error(t('User is not logged in.'), 406);
  }

  watchdog('user', 'Session closed for %name.', array('%name' => $user->name));

  // Destroy the current session.
  module_invoke_all('user_logout', $user);
  session_destroy();

  // Load the anonymous user.
  $user = drupal_anonymous_user();

  return $user;
}
marcingy’s picture

Status: Needs work » Reviewed & tested by the community

This looks good it adds a new field called url so existing data is still in place. In my view no need for a new version.

kylebrowning’s picture

Good call marcingy, ignore #2

ygerasimov’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.