Fix broken media previews
The error log is full of the warning "Warning: copy(public://media-icons/generic/generic.png)" and the media library shows no previews. This can happen when environments are set up based on a database dump and without properly transferring the files. The media icons are usually created during the…
drush php-eval "\Drupal::moduleHandler()->loadInclude('media', 'install');media_install();";
Issue:
The error log is full of the warning "Warning: copy(public://media-icons/generic/generic.png)" and the media library shows no previews. This can happen when environments are set up based on a database dump and without properly transferring the files. The media icons are usually created during the installation of the media module, which will never happen in this scenario.
Solution:
Trigger the install hook of the Core Media module. It will take care of creating those files. Use the provided snippet.
See also https://www.drupal.org/project/drupal/issues/3060509
Ihre Drupal-Website zukunftssicher machen
Wir prüfen Ihr System und zeigen, was Sie für AI, Wartung und Upgrades brauchen.