On Drupal 8 there is by default a user_picture field for the user's photo. When I started my site several months ago, I deleted this field because I did not use it.

enter image description here

Today I need this field, so I created an image type field.

enter image description here

MY PROBLEM : I installed some modules that use the user's photo, but it can not be found because the user_picture is the default

If I create a user_picture field it automatically adds field_ in front of the machine name.

Is it possible to restore the default field with the correct machine name ?


Instead of importing configuration as suggested previously, you could as an alternative, programmatically re-create the field. Here is some code that does that.


use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;

// Create the user profile field and instance.
  'entity_type' => 'user',
  'field_name' => 'user_picture',
  'type' => 'image',
  'translatable' => '0',
  'label' => 'User Picture',
  'description' => '',
  'field_name' => 'user_picture',
  'entity_type' => 'user',
  'bundle' => 'user',
  'required' => 0,

Assuming the code above is placed in a file called recreateUserPicture.php that is stored in your docroot, you can run the following Drush command:

drush scr recreateUserPicture.php

Best of luck!

N.B.: An alternative answer (since the importing of configuration from the standard profile has a problem with having the field being available in Views UI).

  • 1
    @1ad9ac48, you must delete the user_picture field before running the code above. – Stefanos Petrakis Feb 28 '18 at 6:27
  • You can easily run this code by pasting into the interactive shell from running "drush php" – AdamS Nov 26 '18 at 15:12
  • 1
    That was useful Mr. Petrakis ;) – MrUpsidown Feb 28 '20 at 9:41
  • A pleasure to hear that Mr. Upsidown! – Stefanos Petrakis Feb 28 '20 at 20:46

This can be handled using the install configuration that the standard profile holds. Easiest way would be using drupal's console, that would mean following these steps (from inside your docroot):

  1. drupal config:import:single --file=core/profiles/standard/config/install/field.storage.user.user_picture.yml
  2. drupal config:import:single --file=core/profiles/standard/config/install/field.field.user.user.user_picture.yml
  3. drupal update:entities

In case you can't work on the terminal using drupal console, you can import these two configuration from the administrative interface. This can be found under the admin/config/development/configuration/single/import URL (relative to your host's name). From there, you need to import twice, one time the file storage configuration (contents of core/profiles/standard/config/install/field.storage.user.user_picture.yml) and the second would be the file configuration (contents of core/profiles/standard/config/install/field.field.user.user.user_picture.yml).

Hope this helps, good luck!

  • Thank you I updated the question. It does not work – 1ad9ac48 Feb 26 '18 at 18:39
  • Did you try using the admin interface? – Stefanos Petrakis Feb 26 '18 at 18:49
  • There is a problem. The field has been recreated, but it is not available in the views. An idea ? – 1ad9ac48 Feb 27 '18 at 14:49
  • @1ad9ac48, I can reproduce that issue. I haven't figured out why Views does not make the field available. I posted an alternative answer that solves your issue in a programmatic way. – Stefanos Petrakis Feb 28 '18 at 6:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.