diff -u b/core/modules/media_entity/media_entity.info.yml b/core/modules/media_entity/media_entity.info.yml --- b/core/modules/media_entity/media_entity.info.yml +++ b/core/modules/media_entity/media_entity.info.yml @@ -9,3 +9,2 @@ - drupal:user - - drupal:views - drupal:system diff -u b/core/modules/media_entity/src/Entity/Media.php b/core/modules/media_entity/src/Entity/Media.php --- b/core/modules/media_entity/src/Entity/Media.php +++ b/core/modules/media_entity/src/Entity/Media.php @@ -123,22 +123,21 @@ * {@inheritdoc} */ public function getPublisher() { - return $this->get('uid')->entity; + return $this->getOwner(); } /** * {@inheritdoc} */ public function getPublisherId() { - return $this->get('uid')->target_id; + return $this->getOwnerId(); } /** * {@inheritdoc} */ public function setPublisherId($uid) { - $this->set('uid', $uid); - return $this; + return $this->setOwnerId($uid); } /** @@ -160,11 +159,6 @@ $this->setRevisionUserId($this->getOwnerId()); } - // Set thumbnail. - if (!$this->get('thumbnail')->entity) { - $this->automaticallySetThumbnail(); - } - // Try to set fields provided by type plugin and mapped in bundle // configuration. foreach ($this->bundle->entity->getFieldMap() as $source_field => $destination_field) { @@ -180,6 +174,11 @@ $this->set('name', $this->getType()->getDefaultName($this)); } + // Set thumbnail. + if (!$this->get('thumbnail')->entity) { + $this->automaticallySetThumbnail(); + } + } /** @@ -200,7 +199,7 @@ /** @var \Drupal\Core\Entity\EntityStorageInterface $file_storage */ $file_storage = $this->entityTypeManager()->getStorage('file'); - /** @var \Drupal\media_entity\MediaBundleInterface $bundle */ + // If thumbnails should be queued then use default thumbnail, else fetch it. if ($this->bundle->entity->getQueueThumbnailDownloads() && $this->isNew()) { $thumbnail_uri = $this->getType()->getDefaultThumbnail(); } @@ -217,8 +216,8 @@ else { /** @var \Drupal\file\FileInterface $file */ $file = $file_storage->create(['uri' => $thumbnail_uri]); - if ($publisher = $this->getOwner()) { - $file->setOwner($publisher); + if ($owner = $this->getOwner()) { + $file->setOwner($owner); } $file->setPermanent(); $file->save(); @@ -277,8 +276,7 @@ 'label' => 'hidden', 'type' => 'string', 'weight' => -5, - ]) - ->setDisplayConfigurable('view', TRUE); + ]); $fields['thumbnail'] = BaseFieldDefinition::create('image') ->setLabel(t('Thumbnail'))