Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Media.php

function Media::preSave

Overrides ContentEntityBase::preSave

File

core/modules/media/src/Entity/Media.php, line 368

Class

Media
Defines the media entity class.

Namespace

Drupal\media\Entity

Code

public function preSave(EntityStorageInterface $storage) {
    parent::preSave($storage);
    if (!$this->getOwner()) {
        $this->setOwnerId(0);
    }
    // If no thumbnail has been explicitly set, use the default thumbnail.
    if ($this->get('thumbnail')
        ->isEmpty()) {
        $this->thumbnail->target_id = $this->loadThumbnail()
            ->id();
    }
}
RSS feed
Powered by Drupal