- /**
- * {@inheritdoc}
- */
- public function getDefaultName(MediaInterface $media) {
- // The default name will be the filename of the source_field, if present.
- $source_field = $this->configuration['source_field'];
-
- /** @var \Drupal\file\FileInterface $file */
- if (!empty($source_field) && ($file = $media->{$source_field}->entity)) {
- return $file->getFilename();
- }
-
- return parent::getDefaultName($media);
- }
-