Loading bluecheese.theme +7 −2 Original line number Diff line number Diff line Loading @@ -6,6 +6,8 @@ */ use Drupal\Component\Utility\Xss; use Drupal\Core\Cache\CacheableMetadata; use Drupal\file\FileInterface; use Drupal\image\Entity\ImageStyle; use Drupal\user\Entity\User; Loading Loading @@ -51,10 +53,13 @@ function bluecheese_preprocess_node(&$variables) { function bluecheese_preprocess_block(&$variables) { if ($variables['plugin_id'] === 'system_menu_block:account') { $user = User::load(\Drupal::currentUser()->id()); if (user_picture_enabled() && !$user->get('user_picture')->isEmpty()) { $uri = $user->user_picture->first()->entity->getFileUri(); if (user_picture_enabled() && !$user->user_picture->isEmpty() && $user->user_picture->first()->entity instanceof FileInterface) { $file = $user->user_picture->first()->entity; $uri = $file->getFileUri(); $variables['picture'] = ImageStyle::load(theme_get_setting('account_menu_image_style'))->buildUrl($uri); $variables['class'] = 'person'; $cache_metadata = CacheableMetadata::createFromObject($file); $cache_metadata->applyTo($variables); } else { $variables['picture'] = base_path() . \Drupal::service('extension.list.theme')->getPath('bluecheese') . '/images/icon-w-user.svg'; Loading Loading
bluecheese.theme +7 −2 Original line number Diff line number Diff line Loading @@ -6,6 +6,8 @@ */ use Drupal\Component\Utility\Xss; use Drupal\Core\Cache\CacheableMetadata; use Drupal\file\FileInterface; use Drupal\image\Entity\ImageStyle; use Drupal\user\Entity\User; Loading Loading @@ -51,10 +53,13 @@ function bluecheese_preprocess_node(&$variables) { function bluecheese_preprocess_block(&$variables) { if ($variables['plugin_id'] === 'system_menu_block:account') { $user = User::load(\Drupal::currentUser()->id()); if (user_picture_enabled() && !$user->get('user_picture')->isEmpty()) { $uri = $user->user_picture->first()->entity->getFileUri(); if (user_picture_enabled() && !$user->user_picture->isEmpty() && $user->user_picture->first()->entity instanceof FileInterface) { $file = $user->user_picture->first()->entity; $uri = $file->getFileUri(); $variables['picture'] = ImageStyle::load(theme_get_setting('account_menu_image_style'))->buildUrl($uri); $variables['class'] = 'person'; $cache_metadata = CacheableMetadata::createFromObject($file); $cache_metadata->applyTo($variables); } else { $variables['picture'] = base_path() . \Drupal::service('extension.list.theme')->getPath('bluecheese') . '/images/icon-w-user.svg'; Loading