You are here

protected function FacebookAuthManager::getPreferredResolution in Social Auth Facebook 8

Determines preferred profile pic resolution from account settings.

Return order: max resolution, min resolution, FALSE.

Return value

array|false Array of resolution, if defined in Drupal account settings False otherwise

1 call to FacebookAuthManager::getPreferredResolution()
FacebookAuthManager::getFbProfilePicUrl in src/FacebookAuthManager.php
Makes an API call to get the URL of user's Facebook profile picture.

File

src/FacebookAuthManager.php, line 341

Class

FacebookAuthManager
Contains all Simple FB Connect logic that is related to Facebook interaction.

Namespace

Drupal\social_auth_facebook

Code

protected function getPreferredResolution() {
  $field_definitions = $this->entityFieldManager
    ->getFieldDefinitions('user', 'user');
  if (!isset($field_definitions['user_picture'])) {
    return FALSE;
  }
  $max_resolution = $field_definitions['user_picture']
    ->getSetting('max_resolution');
  $min_resolution = $field_definitions['user_picture']
    ->getSetting('min_resolution');

  // Return order: max resolution, min resolution, FALSE.
  if ($max_resolution) {
    $resolution = $max_resolution;
  }
  elseif ($min_resolution) {
    $resolution = $min_resolution;
  }
  else {
    return FALSE;
  }
  $dimensions = explode('x', $resolution);
  return [
    'width' => $dimensions[0],
    'height' => $dimensions[1],
  ];
}