You are here

function social_profile_get_default_image in Open Social 8.5

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_profile/social_profile.module \social_profile_get_default_image()
  2. 8 modules/social_features/social_profile/social_profile.module \social_profile_get_default_image()
  3. 8.2 modules/social_features/social_profile/social_profile.module \social_profile_get_default_image()
  4. 8.3 modules/social_features/social_profile/social_profile.module \social_profile_get_default_image()
  5. 8.4 modules/social_features/social_profile/social_profile.module \social_profile_get_default_image()
  6. 8.6 modules/social_features/social_profile/social_profile.module \social_profile_get_default_image()
  7. 8.7 modules/social_features/social_profile/social_profile.module \social_profile_get_default_image()
  8. 8.8 modules/social_features/social_profile/social_profile.module \social_profile_get_default_image()
  9. 10.3.x modules/social_features/social_profile/social_profile.module \social_profile_get_default_image()
  10. 10.0.x modules/social_features/social_profile/social_profile.module \social_profile_get_default_image()
  11. 10.1.x modules/social_features/social_profile/social_profile.module \social_profile_get_default_image()
  12. 10.2.x modules/social_features/social_profile/social_profile.module \social_profile_get_default_image()

Function to fetch the default profile image.

4 calls to social_profile_get_default_image()
social_event_an_enroll_views_post_render in modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module
Implements hook_views_post_render().
social_profile_fields_profile_view_alter in modules/social_features/social_profile/modules/social_profile_fields/social_profile_fields.module
Implements hook_ENTITY_TYPE_view_alter().
social_profile_profile_view_alter in modules/social_features/social_profile/social_profile.module
Implements hook_ENTITY_TYPE_view_alter().
template_preprocess_activity in modules/custom/activity_creator/activity.page.inc
Prepares variables for Activity templates.

File

modules/social_features/social_profile/social_profile.module, line 581
The Social profile module.

Code

function social_profile_get_default_image() {

  // Load default image.
  $config_factory = \Drupal::configFactory();
  $field_image_config = $config_factory
    ->getEditable('field.field.profile.profile.field_profile_image');
  $default_image = $field_image_config
    ->get('settings.default_image');

  // Load by uuid.
  $files = \Drupal::entityTypeManager()
    ->getStorage('file')
    ->loadByProperties([
    'uuid' => $default_image['uuid'],
  ]);

  // Pop it.
  $file = array_pop($files);

  // Set in an array.
  $data = [
    "id" => $file
      ->id(),
    "width" => $default_image['width'],
    "height" => $default_image['height'],
  ];

  // Retun the array.
  return $data;
}