diff --git a/core/composer.json b/core/composer.json
index 7ae0ccf..e75d742 100644
--- a/core/composer.json
+++ b/core/composer.json
@@ -108,6 +108,7 @@
         "drupal/link": "self.version",
         "drupal/locale": "self.version",
         "drupal/minimal": "self.version",
+        "drupal/media_entity": "self.version",
         "drupal/menu_link_content": "self.version",
         "drupal/menu_ui": "self.version",
         "drupal/migrate": "self.version",
diff --git a/core/modules/media_entity/config/install/media_entity.settings.yml b/core/modules/media_entity/config/install/media_entity.settings.yml
new file mode 100644
index 0000000..85f1c81
--- /dev/null
+++ b/core/modules/media_entity/config/install/media_entity.settings.yml
@@ -0,0 +1 @@
+icon_base: 'public://media-icons/generic'
diff --git a/core/modules/media_entity/config/install/system.action.media_delete_action.yml b/core/modules/media_entity/config/install/system.action.media_delete_action.yml
new file mode 100644
index 0000000..c68b0a5
--- /dev/null
+++ b/core/modules/media_entity/config/install/system.action.media_delete_action.yml
@@ -0,0 +1,10 @@
+langcode: en
+status: true
+dependencies:
+  module:
+    - media_entity
+id: media_delete_action
+label: 'Delete media'
+type: media
+plugin: media_delete_action
+configuration: {  }
diff --git a/core/modules/media_entity/config/install/system.action.media_publish_action.yml b/core/modules/media_entity/config/install/system.action.media_publish_action.yml
new file mode 100644
index 0000000..a5b4959
--- /dev/null
+++ b/core/modules/media_entity/config/install/system.action.media_publish_action.yml
@@ -0,0 +1,10 @@
+langcode: en
+status: true
+dependencies:
+  module:
+    - media_entity
+id: media_publish_action
+label: 'Publish media'
+type: media
+plugin: media_publish_action
+configuration: {  }
diff --git a/core/modules/media_entity/config/install/system.action.media_save_action.yml b/core/modules/media_entity/config/install/system.action.media_save_action.yml
new file mode 100644
index 0000000..fecb8a2
--- /dev/null
+++ b/core/modules/media_entity/config/install/system.action.media_save_action.yml
@@ -0,0 +1,10 @@
+langcode: en
+status: true
+dependencies:
+  module:
+    - media_entity
+id: media_save_action
+label: 'Save media'
+type: media
+plugin: media_save_action
+configuration: {  }
diff --git a/core/modules/media_entity/config/install/system.action.media_unpublish_action.yml b/core/modules/media_entity/config/install/system.action.media_unpublish_action.yml
new file mode 100644
index 0000000..1e87b11
--- /dev/null
+++ b/core/modules/media_entity/config/install/system.action.media_unpublish_action.yml
@@ -0,0 +1,10 @@
+langcode: en
+status: true
+dependencies:
+  module:
+    - media_entity
+id: media_unpublish_action
+label: 'Unpublish media'
+type: media
+plugin: media_unpublish_action
+configuration: {  }
diff --git a/core/modules/media_entity/config/schema/media_entity.schema.yml b/core/modules/media_entity/config/schema/media_entity.schema.yml
new file mode 100644
index 0000000..aafb50e
--- /dev/null
+++ b/core/modules/media_entity/config/schema/media_entity.schema.yml
@@ -0,0 +1,64 @@
+media_entity.settings:
+  type: config_object
+  label: 'Media entity settings'
+  mapping:
+    icon_base:
+      type: string
+      label: 'Base folder for icons installation'
+
+media_entity.bundle.*:
+  type: config_entity
+  label: 'Media bundle'
+  mapping:
+    id:
+      type: string
+      label: 'Machine name'
+    label:
+      type: label
+      label: 'Label'
+    description:
+      type: text
+      label: 'Description'
+    type:
+      type: string
+      label: 'Type plugin ID'
+    queue_thumbnail_downloads:
+      type: boolean
+      label: 'Queue thumbnail downloads'
+    new_revision:
+      type: boolean
+      label: 'Whether a new revision should be created by default'
+    type_configuration:
+      type: media_entity.bundle.type.[%parent.type]
+    field_map:
+      type: sequence
+      label: 'Field map'
+      sequence:
+        type: string
+
+action.configuration.media_delete_action:
+  type: action_configuration_default
+  label: 'Delete media configuration'
+
+action.configuration.media_save_action:
+  type: action_configuration_default
+  label: 'Save media configuration'
+
+action.configuration.media_publish_action:
+  type: action_configuration_default
+  label: 'Publish media configuration'
+
+action.configuration.media_unpublish_action:
+  type: action_configuration_default
+  label: 'Unpublish media configuration'
+
+field.formatter.settings.media_thumbnail:
+  type: mapping
+  label: 'Media thumbnail field display format settings'
+  mapping:
+    image_link:
+      type: string
+      label: 'Link image to'
+    image_style:
+      type: string
+      label: 'Image style'
diff --git a/core/modules/media_entity/config/schema/media_entity.views.schema.yml b/core/modules/media_entity/config/schema/media_entity.views.schema.yml
new file mode 100644
index 0000000..6106249
--- /dev/null
+++ b/core/modules/media_entity/config/schema/media_entity.views.schema.yml
@@ -0,0 +1,5 @@
+# Schema for the views plugins of the Media Entity module.
+
+views.field.media_bulk_form:
+  type: views_field_bulk_form
+  label: 'Media Entity bulk form'
diff --git a/core/modules/media_entity/images/icons/generic.png b/core/modules/media_entity/images/icons/generic.png
new file mode 100644
index 0000000..46125e7
--- /dev/null
+++ b/core/modules/media_entity/images/icons/generic.png
@@ -0,0 +1,8 @@
+PNG
+
+   IHDR         e   tEXtSoftware Adobe ImageReadyqe<  IDATxK*[Q#ʄ2(8T(.*?>񦏋"$>H)iY(DxvGg-"d7gt_ a%           @@@@@@@@@@           @@@@@@@@@@@    3Ѥ;%,rJrS7==-ubB!LܔEAZ???i;gqJ%Bv}nn΂f|dttTlQp:V5Mz-ԗrIqǣB)ioou#!̂f1111<<ޕxE9ONN~uuu"XX]qᇆǍBL(d2L+uc%	qŸe}[[5wds)bwoYww(^v;r4e?nP0%S3sM*GP<55ՅMMMKKK9ԏ
+pp*ahDĴbfqݲ
+VѺB
+{	9dy׸׮ԽiTI4 G!<qoo"s
+?A2ǗsF*jyzucc#T3M9q𸼼M2D?*oD A@@@@@@@P;JԗC4Hnrsl,{~~fo59$C\TD+ʩ<\__777qf>/uGrXKX*J^C:QX*XHqn(et	rR9jntUΕRF"Uk"reJm---Rş8yiHˋQS+~xd!n,lpe3   H뉨#l6i&5%CJ<y?>>nnn!kr4$HDѮ.395H6tH)~E9jMR5吣H>r r r r rșO@9Ltu8^X7rK\A#%L+_V	j|ǳ9~&NgYHR\NC9ޞDoiJ&ڒ+5쫫tl|!lu=a$Y>xwvv<|M0>H       @@@@@@@@@@           @@@@@@@@@@@        5O 
+a?    IENDB`
\ No newline at end of file
diff --git a/core/modules/media_entity/js/media_bundle_form.js b/core/modules/media_entity/js/media_bundle_form.js
new file mode 100644
index 0000000..145fee6
--- /dev/null
+++ b/core/modules/media_entity/js/media_bundle_form.js
@@ -0,0 +1,45 @@
+/**
+ * @file
+ * Javascript for the media bundle form.
+ */
+
+(function ($, Drupal) {
+  'use strict';
+
+  /**
+   * Behaviors for setting summaries on media bundle form.
+   *
+   * @type {Drupal~behavior}
+   *
+   * @prop {Drupal~behaviorAttach} attach
+   *   Attaches summary behaviors on media bundle edit forms.
+   */
+  Drupal.behaviors.mediaBundles = {
+    attach: function (context) {
+      var $context = $(context);
+      // Provide the vertical tab summaries.
+      $context.find('#edit-workflow').drupalSetSummary(function (context) {
+        var vals = [];
+        $(context).find('input[name^="options"]:checked').parent().each(function () {
+          vals.push(Drupal.checkPlain($(this).find('label').text()));
+        });
+        if (!$(context).find('#edit-options-status').is(':checked')) {
+          vals.unshift(Drupal.t('Not published'));
+        }
+        return vals.join(', ');
+      });
+      $('#edit-language', context).drupalSetSummary(function (context) {
+        var vals = [];
+
+        vals.push($('.js-form-item-language-configuration-langcode select option:selected', context).text());
+
+        $('input:checked', context).next('label').each(function () {
+          vals.push(Drupal.checkPlain($(this).text()));
+        });
+
+        return vals.join(', ');
+      });
+    }
+  };
+
+})(jQuery, Drupal);
diff --git a/core/modules/media_entity/js/media_form.js b/core/modules/media_entity/js/media_form.js
new file mode 100644
index 0000000..e8c9547
--- /dev/null
+++ b/core/modules/media_entity/js/media_form.js
@@ -0,0 +1,55 @@
+/**
+ * @file
+ * Defines Javascript behaviors for the media entity form.
+ */
+
+(function ($, Drupal, drupalSettings) {
+
+  'use strict';
+
+  /**
+   * Behaviors for tabs in the media edit form.
+   *
+   * @type {Drupal~behavior}
+   *
+   * @prop {Drupal~behaviorAttach} attach
+   *   Attaches summary behavior for tabs in the media edit form.
+   */
+  Drupal.behaviors.mediaDetailsSummaries = {
+    attach: function (context) {
+      var $context = $(context);
+      $context.find('.media-form-revision-information').drupalSetSummary(function (context) {
+        var $revisionContext = $(context);
+        var revisionCheckbox = $revisionContext.find('.js-form-item-revision input');
+
+        // Return 'New revision' if the 'Create new revision' checkbox is
+        // checked, or if the checkbox doesn't exist, but the revision log does.
+        // For users without the "Administer content" permission the checkbox
+        // won't appear, but the revision log will if the content type is set to
+        // auto-revision.
+        if (revisionCheckbox.is(':checked') || (!revisionCheckbox.length && $revisionContext.find('.js-form-item-revision-log textarea').length)) {
+          return Drupal.t('New revision');
+        }
+
+        return Drupal.t('No revision');
+      });
+
+      $context.find('.media-form-author').drupalSetSummary(function (context) {
+        var $authorContext = $(context);
+        var name = $authorContext.find('.field--name-uid input').val();
+        var date = $authorContext.find('.field--name-created input').val();
+
+        if (name && date) {
+          return Drupal.t('By @name on @date', {'@name': name, '@date': date});
+        }
+        else if (name) {
+          return Drupal.t('By @name', {'@name': name});
+        }
+        else if (date) {
+          return Drupal.t('Authored on @date', {'@date': date});
+        }
+      });
+    }
+  };
+
+})(jQuery, Drupal, drupalSettings);
diff --git a/core/modules/media_entity/media_entity.api.php b/core/modules/media_entity/media_entity.api.php
new file mode 100644
index 0000000..c8eb7b8
--- /dev/null
+++ b/core/modules/media_entity/media_entity.api.php
@@ -0,0 +1,25 @@
+<?php
+
+/**
+ * @file
+ * Hooks related to media entity and it's plugins.
+ */
+
+/**
+ * @addtogroup hooks
+ * @{
+ */
+
+/**
+ * Alter the information provided in \Drupal\media_entity\Annotation\MediaType.
+ *
+ * @param array $types
+ *   The array of type plugins, keyed on the machine-readable name.
+ */
+function hook_media_entity_type_info_alter(&$types) {
+  $types['youtube']['label'] = t('Youtube rocks!');
+}
+
+/**
+ * @} End of "addtogroup hooks".
+ */
diff --git a/core/modules/media_entity/media_entity.info.yml b/core/modules/media_entity/media_entity.info.yml
new file mode 100644
index 0000000..e512d21
--- /dev/null
+++ b/core/modules/media_entity/media_entity.info.yml
@@ -0,0 +1,11 @@
+name: Media entity
+description: 'Media entity API.'
+type: module
+package: Core
+version: VERSION
+core: 8.x
+dependencies:
+  - drupal:image
+  - drupal:user
+  - drupal:views
+  - drupal:system
diff --git a/core/modules/media_entity/media_entity.install b/core/modules/media_entity/media_entity.install
new file mode 100644
index 0000000..1f90470
--- /dev/null
+++ b/core/modules/media_entity/media_entity.install
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * @file
+ * Install, uninstall and update hooks for Media entity module.
+ */
+
+/**
+ * Implements hook_install().
+ */
+function media_entity_install() {
+  $source = drupal_get_path('module', 'media_entity') . '/images/icons';
+  $destination = \Drupal::config('media_entity.settings')->get('icon_base');
+  media_entity_copy_icons($source, $destination);
+}
+
+/**
+ * Implements hook_update_last_removed().
+ */
+function media_entity_update_last_removed() {
+  return 8003;
+}
diff --git a/core/modules/media_entity/media_entity.libraries.yml b/core/modules/media_entity/media_entity.libraries.yml
new file mode 100644
index 0000000..ed0507a
--- /dev/null
+++ b/core/modules/media_entity/media_entity.libraries.yml
@@ -0,0 +1,17 @@
+media_form:
+  version: VERSION
+  js:
+    'js/media_form.js': {}
+  dependencies:
+    - core/jquery
+    - core/drupal
+    - core/drupal.form
+
+media_bundle_form:
+  version: VERSION
+  js:
+    'js/media_bundle_form.js': {}
+  dependencies:
+    - core/jquery
+    - core/drupal
+    - core/drupal.form
diff --git a/core/modules/media_entity/media_entity.links.action.yml b/core/modules/media_entity/media_entity.links.action.yml
new file mode 100644
index 0000000..cb5492c
--- /dev/null
+++ b/core/modules/media_entity/media_entity.links.action.yml
@@ -0,0 +1,11 @@
+media.bundle_add:
+  route_name: entity.media_bundle.add_form
+  title: 'Add media bundle'
+  appears_on:
+    - entity.media_bundle.collection
+
+media.add:
+  route_name: entity.media.add_page
+  title: 'Add media'
+  weight: 10
+
diff --git a/core/modules/media_entity/media_entity.links.contextual.yml b/core/modules/media_entity/media_entity.links.contextual.yml
new file mode 100644
index 0000000..cce5f83
--- /dev/null
+++ b/core/modules/media_entity/media_entity.links.contextual.yml
@@ -0,0 +1,9 @@
+entity.media.edit_form:
+  route_name: entity.media.edit_form
+  group: media
+  title: Edit
+entity.media.delete_form:
+  route_name: entity.media.delete_form
+  group: media
+  title: Delete
+  weight: 10
diff --git a/core/modules/media_entity/media_entity.links.menu.yml b/core/modules/media_entity/media_entity.links.menu.yml
new file mode 100644
index 0000000..713c668
--- /dev/null
+++ b/core/modules/media_entity/media_entity.links.menu.yml
@@ -0,0 +1,11 @@
+entity.media_bundle.collection:
+  title: 'Media bundles'
+  parent: system.admin_structure
+  description: 'Manage media bundles.'
+  route_name: entity.media_bundle.collection
+
+entity.media.add:
+  title: 'Add a new media'
+  parent: entity.media.collection
+  description: 'Add a new media entity.'
+  route_name: entity.media.add_page
diff --git a/core/modules/media_entity/media_entity.links.task.yml b/core/modules/media_entity/media_entity.links.task.yml
new file mode 100644
index 0000000..c044847
--- /dev/null
+++ b/core/modules/media_entity/media_entity.links.task.yml
@@ -0,0 +1,21 @@
+entity.media.canonical:
+  route_name: entity.media.canonical
+  base_route: entity.media.canonical
+  title: 'View'
+entity.media.edit_form:
+  route_name: entity.media.edit_form
+  base_route: entity.media.canonical
+  title: Edit
+entity.media.delete_form:
+  route_name: entity.media.delete_form
+  base_route: entity.media.canonical
+  title: Delete
+  weight: 10
+entity.media_bundle.edit_form:
+  title: 'Edit'
+  route_name: entity.media_bundle.edit_form
+  base_route: entity.media_bundle.edit_form
+entity.media_bundle.collection:
+  title: List
+  route_name: entity.media_bundle.collection
+  base_route: entity.media_bundle.collection
diff --git a/core/modules/media_entity/media_entity.module b/core/modules/media_entity/media_entity.module
new file mode 100644
index 0000000..1ab01e9
--- /dev/null
+++ b/core/modules/media_entity/media_entity.module
@@ -0,0 +1,85 @@
+<?php
+
+/**
+ * @file
+ * Provides media entities.
+ */
+
+use Drupal\Core\Routing\RouteMatchInterface;
+
+/**
+ * Implements hook_help().
+ */
+function media_entity_help($route_name, RouteMatchInterface $route_match) {
+  switch ($route_name) {
+    case 'help.page.media_entity':
+      $output = '<h3>' . t('About') . '</h3>';
+      $output .= '<p>' . t('The <a href=":media_entity_url">Media entity</a> module provides a "base" entity for media. This is a very basic entity which can reference to all kinds of media-objects (local files, YouTube videos, Tweets, Instagram photos, ...). Media entity provides a relation between your website and the media resource. You can reference to/use this entity within any other entity on your site. For more information, see the <a href=":media_entity_handbook">online documentation for the Media entity module</a>.',
+          [
+            ':media_entity_url' => 'https://www.drupal.org/project/media_entity',
+            ':media_entity_handbook' => 'https://drupal-media.gitbooks.io/drupal8-guide/content/modules/media_entity/intro.html',
+          ]) . '</p>';
+      $output .= '<h3>' . t('Uses') . '</h3>';
+      $output .= '<p>' . t('For detailed information about the usage of this module please refer to <a href=":media_entity_handbook">the official documentation</a>.',
+          [
+            ':media_entity_handbook' => 'https://drupal-media.gitbooks.io/drupal8-guide/content/modules/media_entity/intro.html',
+          ]) . '</p>';
+
+      return $output;
+  }
+}
+
+/**
+ * Implements hook_theme().
+ */
+function media_entity_theme() {
+  return [
+    'media' => [
+      'render element' => 'elements',
+      'file' => 'media_entity.theme.inc',
+      'template' => 'media',
+    ],
+  ];
+}
+
+/**
+ * Implements hook_theme_suggestions_HOOK().
+ */
+function media_entity_theme_suggestions_media(array $variables) {
+  $suggestions = [];
+  $media = $variables['elements']['#media'];
+  $sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
+
+  $suggestions[] = 'media__' . $sanitized_view_mode;
+  $suggestions[] = 'media__' . $media->bundle();
+  $suggestions[] = 'media__' . $media->bundle() . '__' . $sanitized_view_mode;
+  $suggestions[] = 'media__' . $media->id();
+  $suggestions[] = 'media__' . $media->id() . '__' . $sanitized_view_mode;
+
+  return $suggestions;
+}
+
+/**
+ * Copy the media file icons to files directory for use with image styles.
+ *
+ * @param string $source
+ *   Source folder.
+ * @param string $destination
+ *   Destination folder.
+ *
+ * @throws Exception
+ *   Thrown when media icons can't be copied to their destination.
+ */
+function media_entity_copy_icons($source, $destination) {
+  if (!file_prepare_directory($destination, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
+    throw new Exception("Unable to create directory $destination.");
+  }
+
+  $files = file_scan_directory($source, '/.*\.(png|jpg)$/');
+  foreach ($files as $file) {
+    $result = file_unmanaged_copy($file->uri, $destination, FILE_EXISTS_REPLACE);
+    if (!$result) {
+      throw new Exception("Unable to copy {$file->uri} to $destination.");
+    }
+  }
+}
diff --git a/core/modules/media_entity/media_entity.permissions.yml b/core/modules/media_entity/media_entity.permissions.yml
new file mode 100644
index 0000000..072259e
--- /dev/null
+++ b/core/modules/media_entity/media_entity.permissions.yml
@@ -0,0 +1,18 @@
+administer media:
+  title: 'Administer media'
+  restrict access: TRUE
+administer media bundles:
+  title: 'Administer media bundles'
+  restrict access: TRUE
+view media:
+  title: 'View media'
+update media:
+  title: 'Update own media'
+update any media:
+  title: 'Update any media'
+delete media:
+  title:  'Delete own media'
+delete any media:
+  title:  'Delete any media'
+create media:
+  title: 'Create media'
diff --git a/core/modules/media_entity/media_entity.routing.yml b/core/modules/media_entity/media_entity.routing.yml
new file mode 100644
index 0000000..b4c75ba
--- /dev/null
+++ b/core/modules/media_entity/media_entity.routing.yml
@@ -0,0 +1,14 @@
+entity.media.multiple_delete_confirm:
+  path: '/admin/content/media/delete'
+  defaults:
+    _form: '\Drupal\media_entity\Form\DeleteMultiple'
+  requirements:
+    _permission: 'delete any media'
+
+entity.media_bundle.collection:
+  path: '/admin/structure/media'
+  defaults:
+    _entity_list: 'media_bundle'
+    _title: 'Media bundles'
+  requirements:
+    _permission: 'administer media bundles'
diff --git a/core/modules/media_entity/media_entity.services.yml b/core/modules/media_entity/media_entity.services.yml
new file mode 100644
index 0000000..a227b73
--- /dev/null
+++ b/core/modules/media_entity/media_entity.services.yml
@@ -0,0 +1,4 @@
+services:
+  plugin.manager.media_entity.type:
+    class: Drupal\media_entity\MediaTypeManager
+    parent: default_plugin_manager
diff --git a/core/modules/media_entity/media_entity.theme.inc b/core/modules/media_entity/media_entity.theme.inc
new file mode 100644
index 0000000..9ccc6f5
--- /dev/null
+++ b/core/modules/media_entity/media_entity.theme.inc
@@ -0,0 +1,40 @@
+<?php
+
+/**
+ * @file
+ * Theme functions for the media_entity module.
+ */
+
+use Drupal\Core\Render\Element;
+use Drupal\Core\Link;
+use Drupal\Component\Utility\Html;
+
+/**
+ * Prepares variables for media templates.
+ *
+ * Default template: media.html.twig.
+ *
+ * @param array $variables
+ *   An associative array containing:
+ *   - media: An individual media for display.
+ */
+function template_preprocess_media(&$variables) {
+  /** @var \Drupal\media_entity\MediaInterface $media */
+  $media = $variables['elements']['#media'];
+
+  $variables['name'] = $media->label();
+
+  // Helpful $content variable for templates.
+  foreach (Element::children($variables['elements']) as $key) {
+    $variables['content'][$key] = $variables['elements'][$key];
+  }
+
+  $variables['attributes']['class'][] = 'media';
+  $variables['attributes']['class'][] = Html::getClass('media-' . $media->bundle());
+  if (!$media->isPublished()) {
+    $variables['attributes']['class'][] = 'unpublished';
+  }
+  if ($variables['elements']['#view_mode']) {
+    $variables['attributes']['class'][] = Html::getClass('view-mode-' . $variables['elements']['#view_mode']);
+  }
+}
diff --git a/core/modules/media_entity/media_entity.tokens.inc b/core/modules/media_entity/media_entity.tokens.inc
new file mode 100644
index 0000000..31f72be
--- /dev/null
+++ b/core/modules/media_entity/media_entity.tokens.inc
@@ -0,0 +1,180 @@
+<?php
+
+/**
+ * @file
+ * Builds placeholder replacement tokens for media_entity-related data.
+ */
+
+use Drupal\Component\Utility\Html;
+use Drupal\Core\Datetime\Entity\DateFormat;
+use Drupal\Core\Language\LanguageInterface;
+use Drupal\Core\Render\BubbleableMetadata;
+use Drupal\media_entity\Entity\MediaBundle;
+
+/**
+ * Implements hook_token_info().
+ */
+function media_entity_token_info() {
+  $type = [
+    'name' => t('Media'),
+    'description' => t('Tokens related to individual media items.'),
+    'needs-data' => 'media',
+  ];
+
+  // Core tokens for media.
+  $media['mid'] = [
+    'name' => t("Media ID"),
+    'description' => t('The unique ID of the media item.'),
+  ];
+  $media['uuid'] = [
+    'name' => t("Media UUID"),
+    'description' => t('The unique UUID of the media item.'),
+  ];
+  $media['vid'] = [
+    'name' => t("Revision ID"),
+    'description' => t("The unique ID of the media's latest revision."),
+  ];
+  $media['bundle'] = [
+    'name' => t("Media bundle"),
+  ];
+  $media['bundle-name'] = [
+    'name' => t("Media bundle name"),
+    'description' => t("The human-readable name of the media bundle."),
+  ];
+  $media['langcode'] = [
+    'name' => t('Language code'),
+    'description' => t('The language code of the language the media is written in.'),
+  ];
+  $media['name'] = [
+    'name' => t('Name'),
+    'description' => t('The name of this media.'),
+  ];
+  $node['author'] = [
+    'name' => t("Author"),
+    'type' => 'user',
+  ];
+  $media['url'] = [
+    'name' => t("URL"),
+    'description' => t("The URL of the media."),
+  ];
+  $media['edit-url'] = [
+    'name' => t("Edit URL"),
+    'description' => t("The URL of the media's edit page."),
+  ];
+
+  // Chained tokens for media.
+  $media['created'] = [
+    'name' => t("Date created"),
+    'type' => 'date',
+  ];
+  $media['changed'] = [
+    'name' => t("Date changed"),
+    'description' => t("The date the media was most recently updated."),
+    'type' => 'date',
+  ];
+
+  return [
+    'types' => ['media' => $type],
+    'tokens' => ['media' => $media],
+  ];
+}
+
+/**
+ * Implements hook_tokens().
+ */
+function media_entity_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
+  $token_service = \Drupal::token();
+
+  $url_options = ['absolute' => TRUE];
+  if (isset($options['langcode'])) {
+    $url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']);
+    $langcode = $options['langcode'];
+  }
+  else {
+    $langcode = LanguageInterface::LANGCODE_DEFAULT;
+  }
+
+  $replacements = [];
+  if ($type == 'media' && !empty($data['media'])) {
+    /** @var \Drupal\media_entity\MediaInterface $media */
+    $media = \Drupal::service('entity.repository')->getTranslationFromContext($data['media'], $langcode, ['operation' => 'media_entity_tokens']);
+
+    foreach ($tokens as $name => $original) {
+      switch ($name) {
+        // Simple key values on the media_entity.
+        case 'mid':
+          $replacements[$original] = $media->id();
+          break;
+
+        case 'uuid':
+          $replacements[$original] = $media->uuid();
+          break;
+
+        case 'vid':
+          $replacements[$original] = $media->getRevisionId();
+          break;
+
+        case 'bundle':
+          $replacements[$original] = $media->bundle();
+          break;
+
+        case 'bundle-name':
+          $replacements[$original] = $media->bundle->entity->label();
+          break;
+
+        case 'langcode':
+          $replacements[$original] = $media->language()->getId();
+          break;
+
+        case 'name':
+          $replacements[$original] = $media->name->value;
+          break;
+
+        case 'url':
+          $replacements[$original] = $media->toUrl('canonical', $url_options);
+          break;
+
+        case 'edit-url':
+          $replacements[$original] = $media->toUrl('edit-form', $url_options);
+          break;
+
+        // Default values for the chained tokens handled below.
+        case 'author':
+          /** @var \Drupal\user\UserInterface $account */
+          $account = $media->getPublisher();
+          $bubbleable_metadata->addCacheableDependency($account);
+          $replacements[$original] = $account->label();
+          break;
+
+        case 'created':
+          $date_format = DateFormat::load('medium');
+          $bubbleable_metadata->addCacheableDependency($date_format);
+          $replacements[$original] = \Drupal::service('date.formatter')
+            ->format($media->getCreatedTime(), 'medium', '', NULL, $langcode);
+          break;
+
+        case 'changed':
+          $date_format = DateFormat::load('medium');
+          $bubbleable_metadata->addCacheableDependency($date_format);
+          $replacements[$original] = \Drupal::service('date.formatter')
+            ->format($media->getChangedTime(), 'medium', '', NULL, $langcode);
+          break;
+      }
+    }
+
+    if ($author_tokens = $token_service->findWithPrefix($tokens, 'author')) {
+      $account = $media->get('uid')->entity;
+      $replacements += $token_service->generate('user', $author_tokens, ['user' => $account], $options, $bubbleable_metadata);
+    }
+
+    if ($created_tokens = $token_service->findWithPrefix($tokens, 'created')) {
+      $replacements += $token_service->generate('date', $created_tokens, ['date' => $media->getCreatedTime()], $options, $bubbleable_metadata);
+    }
+
+    if ($changed_tokens = $token_service->findWithPrefix($tokens, 'changed')) {
+      $replacements += $token_service->generate('date', $changed_tokens, ['date' => $media->getChangedTime()], $options, $bubbleable_metadata);
+    }
+  }
+
+  return $replacements;
+}
diff --git a/core/modules/media_entity/src/Annotation/MediaType.php b/core/modules/media_entity/src/Annotation/MediaType.php
new file mode 100644
index 0000000..65a3d70
--- /dev/null
+++ b/core/modules/media_entity/src/Annotation/MediaType.php
@@ -0,0 +1,43 @@
+<?php
+
+namespace Drupal\media_entity\Annotation;
+
+use Drupal\Component\Annotation\Plugin;
+
+/**
+ * Defines an media entity type plugin annotation object.
+ *
+ * @see hook_media_entity_type_info_alter()
+ *
+ * @Annotation
+ */
+class MediaType extends Plugin {
+
+  /**
+   * The plugin ID.
+   *
+   * @var string
+   */
+  public $id;
+
+  /**
+   * The human-readable name of the type.
+   *
+   * @ingroup plugin_translatable
+   *
+   * @var \Drupal\Core\Annotation\Translation
+   */
+  public $label;
+
+  /**
+   * A brief description of the plugin.
+   *
+   * This will be shown when adding or configuring this display.
+   *
+   * @ingroup plugin_translatable
+   *
+   * @var \Drupal\Core\Annotation\Translation (optional)
+   */
+  public $description = '';
+
+}
diff --git a/core/modules/media_entity/src/EmbedCodeValueTrait.php b/core/modules/media_entity/src/EmbedCodeValueTrait.php
new file mode 100644
index 0000000..b9acaca
--- /dev/null
+++ b/core/modules/media_entity/src/EmbedCodeValueTrait.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Drupal\media_entity;
+
+use Drupal\Core\Field\FieldItemInterface;
+
+/**
+ * A trait to assist with handling external embed codes.
+ */
+trait EmbedCodeValueTrait {
+
+  /**
+   * Extracts the raw embed code from input which may or may not be wrapped.
+   *
+   * @param mixed $value
+   *   The input value. Can be a normal string or a value wrapped by the
+   *   Typed Data API.
+   *
+   * @return string|null
+   *   The raw embed code.
+   */
+  protected function getEmbedCode($value) {
+    if (is_string($value)) {
+      return $value;
+    }
+    elseif ($value instanceof FieldItemInterface) {
+      $class = get_class($value);
+      $property = $class::mainPropertyName();
+      if ($property) {
+        return $value->$property;
+      }
+    }
+  }
+
+}
diff --git a/core/modules/media_entity/src/Entity/Media.php b/core/modules/media_entity/src/Entity/Media.php
new file mode 100644
index 0000000..833e3f2
--- /dev/null
+++ b/core/modules/media_entity/src/Entity/Media.php
@@ -0,0 +1,459 @@
+<?php
+
+namespace Drupal\media_entity\Entity;
+
+use Drupal\Core\Entity\ContentEntityBase;
+use Drupal\Core\Entity\EntityStorageInterface;
+use Drupal\Core\Entity\EntityTypeInterface;
+use Drupal\Core\Field\BaseFieldDefinition;
+use Drupal\media_entity\MediaInterface;
+use Drupal\Core\Entity\EntityChangedTrait;
+use Drupal\user\UserInterface;
+
+/**
+ * Defines the media entity class.
+ *
+ * @ContentEntityType(
+ *   id = "media",
+ *   label = @Translation("Media"),
+ *   bundle_label = @Translation("Media bundle"),
+ *   handlers = {
+ *     "storage" = "Drupal\Core\Entity\Sql\SqlContentEntityStorage",
+ *     "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
+ *     "list_builder" = "Drupal\Core\Entity\EntityListBuilder",
+ *     "access" = "Drupal\media_entity\MediaAccessController",
+ *     "form" = {
+ *       "default" = "Drupal\media_entity\MediaForm",
+ *       "delete" = "Drupal\media_entity\Form\MediaDeleteForm",
+ *       "edit" = "Drupal\media_entity\MediaForm"
+ *     },
+ *     "translation" = "Drupal\content_translation\ContentTranslationHandler",
+ *     "views_data" = "Drupal\media_entity\MediaViewsData",
+ *     "route_provider" = {
+ *       "html" = "Drupal\Core\Entity\Routing\AdminHtmlRouteProvider",
+ *     }
+ *   },
+ *   base_table = "media",
+ *   data_table = "media_field_data",
+ *   revision_table = "media_revision",
+ *   revision_data_table = "media_field_revision",
+ *   translatable = TRUE,
+ *   render_cache = TRUE,
+ *   entity_keys = {
+ *     "id" = "mid",
+ *     "revision" = "vid",
+ *     "bundle" = "bundle",
+ *     "label" = "name",
+ *     "langcode" = "langcode",
+ *     "uuid" = "uuid"
+ *   },
+ *   bundle_entity_type = "media_bundle",
+ *   permission_granularity = "entity_type",
+ *   admin_permission = "administer media",
+ *   field_ui_base_route = "entity.media_bundle.edit_form",
+ *   links = {
+ *     "add-page" = "/media/add",
+ *     "add-form" = "/media/add/{media_bundle}",
+ *     "canonical" = "/media/{media}",
+ *     "delete-form" = "/media/{media}/delete",
+ *     "edit-form" = "/media/{media}/edit",
+ *     "admin-form" = "/admin/structure/media/manage/{media_bundle}"
+ *   }
+ * )
+ */
+class Media extends ContentEntityBase implements MediaInterface {
+
+  use EntityChangedTrait;
+
+  /**
+   * Value that represents the media being published.
+   */
+  const PUBLISHED = 1;
+
+  /**
+   * Value that represents the media being unpublished.
+   */
+  const NOT_PUBLISHED = 0;
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getCreatedTime() {
+    return $this->get('created')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setCreatedTime($timestamp) {
+    $this->set('created', $timestamp);
+    return $this;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isPublished() {
+    return (bool) $this->get('status')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setPublished($published) {
+    $this->set('status', $published ? Media::PUBLISHED : Media::NOT_PUBLISHED);
+    return $this;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getOwner() {
+    $this->get('uid')->entity;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setOwner(UserInterface $account) {
+    $this->set('uid', $account->id());
+    return $this;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getOwnerId() {
+    $this->get('uid')->target_id;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setOwnerId($uid) {
+    $this->set('uid', $uid);
+    return $this;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getPublisher() {
+    return $this->get('uid')->entity;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getPublisherId() {
+    return $this->get('uid')->target_id;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setPublisherId($uid) {
+    $this->set('uid', $uid);
+    return $this;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getType() {
+    return $this->bundle->entity->getType();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function preSave(EntityStorageInterface $storage) {
+    parent::preSave($storage);
+
+    // If no revision author has been set explicitly, make the media owner the
+    // revision author.
+    if (!$this->get('revision_uid')->entity) {
+      $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) {
+      // Only save value in entity field if empty. Do not overwrite existing
+      // data.
+      if ($this->hasField($destination_field) && $this->{$destination_field}->isEmpty() && ($value = $this->getType()->getField($this, $source_field))) {
+        $this->set($destination_field, $value);
+      }
+    }
+
+    // Try to set a default name for this media, if there is no label provided.
+    if (empty($this->label())) {
+      $this->set('name', $this->getType()->getDefaultName($this));
+    }
+
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function postSave(EntityStorageInterface $storage, $update = TRUE) {
+    parent::postSave($storage, $update);
+    if (!$update && $this->bundle->entity->getQueueThumbnailDownloads()) {
+      $queue = \Drupal::queue('media_entity_thumbnail');
+      $queue->createItem(['id' => $this->id()]);
+    }
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function automaticallySetThumbnail() {
+    /** @var \Drupal\media_entity\MediaBundleInterface $bundle */
+    if ($this->bundle->entity->getQueueThumbnailDownloads() && $this->isNew()) {
+      $thumbnail_uri = $this->getType()->getDefaultThumbnail();
+    }
+    else {
+      $thumbnail_uri = $this->getType()->thumbnail($this);
+    }
+    $existing = \Drupal::entityQuery('file')
+      ->condition('uri', $thumbnail_uri)
+      ->execute();
+
+    if ($existing) {
+      $this->thumbnail->target_id = reset($existing);
+    }
+    else {
+      /** @var \Drupal\file\FileInterface $file */
+      $file = $this->entityTypeManager()->getStorage('file')->create(['uri' => $thumbnail_uri]);
+      if ($publisher = $this->getOwner()) {
+        $file->setOwner($publisher);
+      }
+      $file->setPermanent();
+      $file->save();
+      $this->thumbnail->target_id = $file->id();
+    }
+
+    // TODO - We should probably use something smarter (tokens, ...).
+    $this->thumbnail->alt = t('Thumbnail');
+    $this->thumbnail->title = $this->label();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record) {
+    parent::preSaveRevision($storage, $record);
+
+    if (!$this->isNewRevision() && isset($this->original) && (!isset($record->revision_log) || $record->revision_log === '')) {
+      // If we are updating an existing node without adding a new revision, we
+      // need to make sure $entity->revision_log is reset whenever it is empty.
+      // Therefore, this code allows us to avoid clobbering an existing log
+      // entry with an empty one.
+      $record->revision_log = $this->original->revision_log->value;
+    }
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function validate() {
+    $this->getType()->attachConstraints($this);
+    return parent::validate();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
+    $fields = parent::baseFieldDefinitions($entity_type);
+
+    $fields['name'] = BaseFieldDefinition::create('string')
+      ->setLabel(t('Media name'))
+      ->setDescription(t('The name of this media.'))
+      ->setRequired(TRUE)
+      ->setTranslatable(TRUE)
+      ->setRevisionable(TRUE)
+      ->setDefaultValue('')
+      ->setSetting('max_length', 255)
+      ->setDisplayOptions('form', [
+        'type' => 'string_textfield',
+        'weight' => -5,
+      ])
+      ->setDisplayConfigurable('form', TRUE)
+      ->setDisplayOptions('view', [
+        'label' => 'hidden',
+        'type' => 'string',
+        'weight' => -5,
+      ])
+      ->setDisplayConfigurable('view', TRUE);
+
+    $fields['thumbnail'] = BaseFieldDefinition::create('image')
+      ->setLabel(t('Thumbnail'))
+      ->setDescription(t('The thumbnail of the media.'))
+      ->setRevisionable(TRUE)
+      ->setDisplayOptions('view', [
+        'type' => 'image',
+        'weight' => 1,
+        'label' => 'hidden',
+        'settings' => [
+          'image_style' => 'thumbnail',
+        ],
+      ])
+      ->setDisplayConfigurable('view', TRUE)
+      ->setReadOnly(TRUE);
+
+    $fields['uid'] = BaseFieldDefinition::create('entity_reference')
+      ->setLabel(t('Publisher ID'))
+      ->setDescription(t('The user ID of the media publisher.'))
+      ->setRevisionable(TRUE)
+      ->setDefaultValueCallback('Drupal\media_entity\Entity\Media::getCurrentUserId')
+      ->setSetting('target_type', 'user')
+      ->setTranslatable(TRUE)
+      ->setDisplayOptions('view', [
+        'label' => 'hidden',
+        'type' => 'author',
+        'weight' => 0,
+      ])
+      ->setDisplayConfigurable('view', TRUE)
+      ->setDisplayOptions('form', [
+        'type' => 'entity_reference_autocomplete',
+        'weight' => 5,
+        'settings' => [
+          'match_operator' => 'CONTAINS',
+          'size' => '60',
+          'autocomplete_type' => 'tags',
+          'placeholder' => '',
+        ],
+      ])
+      ->setDisplayConfigurable('form', TRUE);
+
+    $fields['status'] = BaseFieldDefinition::create('boolean')
+      ->setLabel(t('Publishing status'))
+      ->setDescription(t('A boolean indicating whether the media is published.'))
+      ->setTranslatable(TRUE)
+      ->setRevisionable(TRUE)
+      ->setDefaultValue(TRUE);
+
+    $fields['created'] = BaseFieldDefinition::create('created')
+      ->setLabel(t('Created'))
+      ->setDescription(t('The time that the media was created.'))
+      ->setTranslatable(TRUE)
+      ->setRevisionable(TRUE)
+      ->setDisplayOptions('view', [
+        'label' => 'hidden',
+        'type' => 'timestamp',
+        'weight' => 0,
+      ])
+      ->setDisplayConfigurable('view', TRUE)
+      ->setDisplayOptions('form', [
+        'type' => 'datetime_timestamp',
+        'weight' => 10,
+      ])
+      ->setDisplayConfigurable('form', TRUE);
+
+    $fields['changed'] = BaseFieldDefinition::create('changed')
+      ->setLabel(t('Changed'))
+      ->setDescription(t('The time that the media was last edited.'))
+      ->setTranslatable(TRUE)
+      ->setRevisionable(TRUE);
+
+    $fields['revision_timestamp'] = BaseFieldDefinition::create('created')
+      ->setLabel(t('Revision timestamp'))
+      ->setDescription(t('The time that the current revision was created.'))
+      ->setQueryable(FALSE)
+      ->setRevisionable(TRUE);
+
+    $fields['revision_uid'] = BaseFieldDefinition::create('entity_reference')
+      ->setLabel(t('Revision publisher ID'))
+      ->setDescription(t('The user ID of the publisher of the current revision.'))
+      ->setSetting('target_type', 'user')
+      ->setQueryable(FALSE)
+      ->setRevisionable(TRUE);
+
+    $fields['revision_log'] = BaseFieldDefinition::create('string_long')
+      ->setLabel(t('Revision Log'))
+      ->setDescription(t('The log entry explaining the changes in this revision.'))
+      ->setRevisionable(TRUE)
+      ->setTranslatable(TRUE);
+
+    return $fields;
+  }
+
+  /**
+   * Default value callback for 'uid' base field definition.
+   *
+   * @see ::baseFieldDefinitions()
+   *
+   * @return array
+   *   An array of default values.
+   */
+  public static function getCurrentUserId() {
+    return [\Drupal::currentUser()->id()];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getRevisionCreationTime() {
+    return $this->revision_timestamp->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setRevisionCreationTime($timestamp) {
+    $this->revision_timestamp->value = $timestamp;
+    return $this;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getRevisionUser() {
+    return $this->revision_uid->entity;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setRevisionUser(UserInterface $account) {
+    $this->revision_uid->entity = $account;
+    return $this;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getRevisionUserId() {
+    return $this->revision_uid->target_id;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setRevisionUserId($user_id) {
+    $this->revision_uid->target_id = $user_id;
+    return $this;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getRevisionLogMessage() {
+    return $this->revision_log->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setRevisionLogMessage($revision_log_message) {
+    $this->revision_log->value = $revision_log_message;
+    return $this;
+  }
+
+}
diff --git a/core/modules/media_entity/src/Entity/MediaBundle.php b/core/modules/media_entity/src/Entity/MediaBundle.php
new file mode 100644
index 0000000..c98a098
--- /dev/null
+++ b/core/modules/media_entity/src/Entity/MediaBundle.php
@@ -0,0 +1,244 @@
+<?php
+
+namespace Drupal\media_entity\Entity;
+
+use Drupal\Core\Entity\EntityDescriptionInterface;
+use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
+use Drupal\Core\Entity\EntityWithPluginCollectionInterface;
+use Drupal\Core\Plugin\DefaultSingleLazyPluginCollection;
+use Drupal\media_entity\MediaBundleInterface;
+use Drupal\media_entity\MediaInterface;
+
+/**
+ * Defines the Media bundle configuration entity.
+ *
+ * @ConfigEntityType(
+ *   id = "media_bundle",
+ *   label = @Translation("Media bundle"),
+ *   handlers = {
+ *     "form" = {
+ *       "add" = "Drupal\media_entity\MediaBundleForm",
+ *       "edit" = "Drupal\media_entity\MediaBundleForm",
+ *       "delete" = "Drupal\media_entity\Form\MediaBundleDeleteConfirm"
+ *     },
+ *     "list_builder" = "Drupal\media_entity\MediaBundleListBuilder",
+ *     "route_provider" = {
+ *       "html" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
+ *     }
+ *   },
+ *   admin_permission = "administer media bundles",
+ *   config_prefix = "bundle",
+ *   bundle_of = "media",
+ *   entity_keys = {
+ *     "id" = "id",
+ *     "label" = "label"
+ *   },
+ *   config_export = {
+ *     "id",
+ *     "label",
+ *     "description",
+ *     "type",
+ *     "queue_thumbnail_downloads",
+ *     "new_revision",
+ *     "third_party_settings",
+ *     "type_configuration",
+ *     "field_map",
+ *     "status",
+ *   },
+ *   links = {
+ *     "add-form" = "/admin/structure/media/add",
+ *     "edit-form" = "/admin/structure/media/manage/{media_bundle}",
+ *     "delete-form" = "/admin/structure/media/manage/{media_bundle}/delete",
+ *     "collection" = "/admin/structure/media",
+ *   }
+ * )
+ */
+class MediaBundle extends ConfigEntityBundleBase implements MediaBundleInterface, EntityWithPluginCollectionInterface, EntityDescriptionInterface {
+
+  /**
+   * The machine name of this media bundle.
+   *
+   * @var string
+   */
+  public $id;
+
+  /**
+   * The human-readable name of the media bundle.
+   *
+   * @var string
+   */
+  public $label;
+
+  /**
+   * A brief description of this media bundle.
+   *
+   * @var string
+   */
+  public $description;
+
+  /**
+   * The type plugin id.
+   *
+   * @var string
+   */
+  public $type = 'generic';
+
+  /**
+   * Are thumbnail downloads queued.
+   *
+   * @var bool
+   */
+  public $queue_thumbnail_downloads = FALSE;
+
+  /**
+   * Default value of the 'Create new revision' checkbox of this media bundle.
+   *
+   * @var bool
+   */
+  protected $new_revision = FALSE;
+
+  /**
+   * The type plugin configuration.
+   *
+   * @var array
+   */
+  public $type_configuration = [];
+
+  /**
+   * Type lazy plugin collection.
+   *
+   * @var \Drupal\Core\Plugin\DefaultSingleLazyPluginCollection
+   */
+  protected $typePluginCollection;
+
+  /**
+   * Field map. Fields provided by type plugin to be stored as entity fields.
+   *
+   * @var array
+   */
+  public $field_map = [];
+
+  /**
+   * Default status of this media bundle.
+   *
+   * @var array
+   */
+  public $status = TRUE;
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getPluginCollections() {
+    return [
+      'type_configuration' => $this->typePluginCollection(),
+    ];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function getLabel(MediaInterface $media) {
+    $bundle = static::load($media->bundle());
+    return $bundle ? $bundle->label() : FALSE;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function exists($id) {
+    return (bool) static::load($id);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getDescription() {
+    return $this->description;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setDescription($description) {
+    $this->description = $description;
+    return $this;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getTypeConfiguration() {
+    return $this->type_configuration;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setTypeConfiguration($configuration) {
+    $this->type_configuration = $configuration;
+    $this->typePluginCollection = NULL;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getQueueThumbnailDownloads() {
+    return $this->queue_thumbnail_downloads;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setQueueThumbnailDownloads($queue_thumbnail_downloads) {
+    $this->queue_thumbnail_downloads = $queue_thumbnail_downloads;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getType() {
+    return $this->typePluginCollection()->get($this->type);
+  }
+
+  /**
+   * Returns type lazy plugin collection.
+   *
+   * @return \Drupal\Core\Plugin\DefaultSingleLazyPluginCollection
+   *   The tag plugin collection.
+   */
+  protected function typePluginCollection() {
+    if (!$this->typePluginCollection) {
+      $this->typePluginCollection = new DefaultSingleLazyPluginCollection(\Drupal::service('plugin.manager.media_entity.type'), $this->type, $this->type_configuration);
+    }
+    return $this->typePluginCollection;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getStatus() {
+    return $this->status;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function shouldCreateNewRevision() {
+    return $this->new_revision;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setNewRevision($new_revision) {
+    $this->new_revision = $new_revision;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getFieldMap() {
+    return $this->field_map;
+  }
+
+}
diff --git a/core/modules/media_entity/src/Form/DeleteMultiple.php b/core/modules/media_entity/src/Form/DeleteMultiple.php
new file mode 100644
index 0000000..2a9cc40
--- /dev/null
+++ b/core/modules/media_entity/src/Form/DeleteMultiple.php
@@ -0,0 +1,199 @@
+<?php
+
+namespace Drupal\media_entity\Form;
+
+use Drupal\Core\Entity\EntityTypeManagerInterface;
+use Drupal\Core\Form\ConfirmFormBase;
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Url;
+use Drupal\user\PrivateTempStoreFactory;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\HttpFoundation\RedirectResponse;
+
+/**
+ * Provides a media deletion confirmation form.
+ */
+class DeleteMultiple extends ConfirmFormBase {
+
+  /**
+   * The array of media entities to delete.
+   *
+   * @var string[][]
+   */
+  protected $entityInfo = [];
+
+  /**
+   * The tempstore factory.
+   *
+   * @var \Drupal\user\PrivateTempStoreFactory
+   */
+  protected $tempStoreFactory;
+
+  /**
+   * The entity storage.
+   *
+   * @var \Drupal\Core\Entity\EntityStorageInterface
+   */
+  protected $storage;
+
+  /**
+   * Constructs a DeleteMultiple form object.
+   *
+   * @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory
+   *   The tempstore factory.
+   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $manager
+   *   The entity manager.
+   */
+  public function __construct(PrivateTempStoreFactory $temp_store_factory, EntityTypeManagerInterface $manager) {
+    $this->tempStoreFactory = $temp_store_factory;
+    $this->storage = $manager->getStorage('media');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container) {
+    return new static(
+      $container->get('user.private_tempstore'),
+      $container->get('entity_type.manager')
+    );
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getFormId() {
+    return 'media_multiple_delete_confirm';
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getQuestion() {
+    return $this->formatPlural(count($this->entityInfo), 'Are you sure you want to delete this item?', 'Are you sure you want to delete these items?');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getCancelUrl() {
+    return new Url('system.admin_content');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getConfirmText() {
+    return $this->t('Delete');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildForm(array $form, FormStateInterface $form_state) {
+    $this->entityInfo = $this->tempStoreFactory->get('media_multiple_delete_confirm')->get(\Drupal::currentUser()->id());
+    if (empty($this->entityInfo)) {
+      return new RedirectResponse($this->getCancelUrl()->setAbsolute()->toString());
+    }
+    /** @var \Drupal\media_entity\MediaInterface[] $entities */
+    $entities = $this->storage->loadMultiple(array_keys($this->entityInfo));
+
+    $items = [];
+    foreach ($this->entityInfo as $id => $langcodes) {
+      foreach ($langcodes as $langcode) {
+        $entity = $entities[$id]->getTranslation($langcode);
+        $key = $id . ':' . $langcode;
+        $default_key = $id . ':' . $entity->getUntranslated()->language()->getId();
+
+        // If we have a translated entity we build a nested list of translations
+        // that will be deleted.
+        $languages = $entity->getTranslationLanguages();
+        if (count($languages) > 1 && $entity->isDefaultTranslation()) {
+          $names = [];
+          foreach ($languages as $translation_langcode => $language) {
+            $names[] = $language->getName();
+            unset($items[$id . ':' . $translation_langcode]);
+          }
+          $items[$default_key] = [
+            'label' => [
+              '#markup' => $this->t('@label (Original translation) - <em>The following media translations will be deleted:</em>', ['@label' => $entity->label()]),
+            ],
+            'deleted_translations' => [
+              '#theme' => 'item_list',
+              '#items' => $names,
+            ],
+          ];
+        }
+        elseif (!isset($items[$default_key])) {
+          $items[$key] = $entity->label();
+        }
+      }
+    }
+
+    $form['entities'] = [
+      '#theme' => 'item_list',
+      '#items' => $items,
+    ];
+    $form = parent::buildForm($form, $form_state);
+
+    return $form;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function submitForm(array &$form, FormStateInterface $form_state) {
+    if ($form_state->getValue('confirm') && !empty($this->entityInfo)) {
+      $total_count = 0;
+      $delete_entities = [];
+      /** @var \Drupal\Core\Entity\ContentEntityInterface[][] $delete_translations */
+      $delete_translations = [];
+      /** @var \Drupal\media_entity\MediaInterface[] $entities */
+      $entities = $this->storage->loadMultiple(array_keys($this->entityInfo));
+
+      foreach ($this->entityInfo as $id => $langcodes) {
+        foreach ($langcodes as $langcode) {
+          $entity = $entities[$id]->getTranslation($langcode);
+          if ($entity->isDefaultTranslation()) {
+            $delete_entities[$id] = $entity;
+            unset($delete_translations[$id]);
+            $total_count += count($entity->getTranslationLanguages());
+          }
+          elseif (!isset($delete_entities[$id])) {
+            $delete_translations[$id][] = $entity;
+          }
+        }
+      }
+
+      if ($delete_entities) {
+        $this->storage->delete($delete_entities);
+        $this->logger('media_entity')->notice('Deleted @count media entities.', ['@count' => count($delete_entities)]);
+      }
+
+      if ($delete_translations) {
+        $count = 0;
+        foreach ($delete_translations as $id => $translations) {
+          $entity = $entities[$id]->getUntranslated();
+          foreach ($translations as $translation) {
+            $entity->removeTranslation($translation->language()->getId());
+          }
+          $entity->save();
+          $count += count($translations);
+        }
+        if ($count) {
+          $total_count += $count;
+          $this->logger('media_entity')->notice('Deleted @count media translations.', ['@count' => $count]);
+        }
+      }
+
+      if ($total_count) {
+        drupal_set_message($this->formatPlural($total_count, 'Deleted 1 media entity.', 'Deleted @count media entities.'));
+      }
+
+      $this->tempStoreFactory->get('media_multiple_delete_confirm')->delete(\Drupal::currentUser()->id());
+    }
+
+    $form_state->setRedirect('system.admin_content');
+  }
+
+}
diff --git a/core/modules/media_entity/src/Form/MediaBundleDeleteConfirm.php b/core/modules/media_entity/src/Form/MediaBundleDeleteConfirm.php
new file mode 100644
index 0000000..f860eb4
--- /dev/null
+++ b/core/modules/media_entity/src/Form/MediaBundleDeleteConfirm.php
@@ -0,0 +1,59 @@
+<?php
+
+namespace Drupal\media_entity\Form;
+
+use Drupal\Core\Entity\Query\QueryFactory;
+use Drupal\Core\Entity\EntityDeleteForm;
+use Drupal\Core\Form\FormStateInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * Provides a form for media bundle deletion.
+ */
+class MediaBundleDeleteConfirm extends EntityDeleteForm {
+
+  /**
+   * The query factory to create entity queries.
+   *
+   * @var \Drupal\Core\Entity\Query\QueryFactory
+   */
+  protected $queryFactory;
+
+  /**
+   * Constructs a new MediaBundleDeleteConfirm object.
+   *
+   * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory
+   *   The entity query object.
+   */
+  public function __construct(QueryFactory $query_factory) {
+    $this->queryFactory = $query_factory;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container) {
+    return new static(
+      $container->get('entity.query')
+    );
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildForm(array $form, FormStateInterface $form_state) {
+    $num_entities = $this->queryFactory->get('media')
+      ->condition('bundle', $this->entity->id())
+      ->count()
+      ->execute();
+    if ($num_entities) {
+      $caption = '<p>' . $this->formatPlural($num_entities, '%type is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the %type content.', '%type is used by @count pieces of content on your site. You may not remove %type until you have removed all of the %type content.', ['%type' => $this->entity->label()]) . '</p>';
+      $form['#title'] = $this->getQuestion();
+      $form['description'] = ['#markup' => $caption];
+      return $form;
+    }
+
+    return parent::buildForm($form, $form_state);
+  }
+
+}
diff --git a/core/modules/media_entity/src/Form/MediaDeleteForm.php b/core/modules/media_entity/src/Form/MediaDeleteForm.php
new file mode 100644
index 0000000..d84e34a
--- /dev/null
+++ b/core/modules/media_entity/src/Form/MediaDeleteForm.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace Drupal\media_entity\Form;
+
+use Drupal\Core\Entity\ContentEntityDeleteForm;
+use Drupal\Core\Url;
+
+/**
+ * Provides a form for deleting a media.
+ */
+class MediaDeleteForm extends ContentEntityDeleteForm {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getCancelUrl() {
+    return Url::fromUri('internal:/');
+  }
+
+}
diff --git a/core/modules/media_entity/src/MediaAccessController.php b/core/modules/media_entity/src/MediaAccessController.php
new file mode 100644
index 0000000..5b09787
--- /dev/null
+++ b/core/modules/media_entity/src/MediaAccessController.php
@@ -0,0 +1,46 @@
+<?php
+
+namespace Drupal\media_entity;
+
+use Drupal\Core\Access\AccessResult;
+use Drupal\Core\Entity\EntityAccessControlHandler;
+use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Session\AccountInterface;
+
+/**
+ * Defines an access controller for the media entity.
+ */
+class MediaAccessController extends EntityAccessControlHandler {
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
+    if ($account->hasPermission('administer media')) {
+      return AccessResult::allowed()->cachePerPermissions();
+    }
+
+    $is_owner = ($account->id() && $account->id() == $entity->getPublisherId()) ? TRUE : FALSE;
+    switch ($operation) {
+      case 'view':
+        return AccessResult::allowedIf($account->hasPermission('view media') && $entity->status->value);
+
+      case 'update':
+        return AccessResult::allowedIf(($account->hasPermission('update media') && $is_owner) || $account->hasPermission('update any media'))->cachePerPermissions()->cachePerUser()->addCacheableDependency($entity);
+
+      case 'delete':
+        return AccessResult::allowedIf(($account->hasPermission('delete media') && $is_owner) ||  $account->hasPermission('delete any media'))->cachePerPermissions()->cachePerUser()->addCacheableDependency($entity);
+    }
+
+    // No opinion.
+    return AccessResult::neutral()->cachePerPermissions();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
+    return AccessResult::allowedIfHasPermission($account, 'create media');
+  }
+
+}
diff --git a/core/modules/media_entity/src/MediaBundleForm.php b/core/modules/media_entity/src/MediaBundleForm.php
new file mode 100644
index 0000000..66f0cca
--- /dev/null
+++ b/core/modules/media_entity/src/MediaBundleForm.php
@@ -0,0 +1,386 @@
+<?php
+
+namespace Drupal\media_entity;
+
+use Drupal\Core\Ajax\AjaxResponse;
+use Drupal\Core\Ajax\ReplaceCommand;
+use Drupal\Core\Entity\EntityFieldManagerInterface;
+use Drupal\Core\Entity\EntityForm;
+use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\language\Entity\ContentLanguageSettings;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * Form controller for node type forms.
+ */
+class MediaBundleForm extends EntityForm {
+
+  /**
+   * The instantiated plugin instances that have configuration forms.
+   *
+   * @var \Drupal\Core\Plugin\PluginFormInterface[]
+   */
+  protected $configurableInstances = [];
+
+  /**
+   * Manager for media entity type plugins.
+   *
+   * @var \Drupal\media_entity\MediaTypeManager
+   */
+  protected $mediaTypeManager;
+
+  /**
+   * Entity field manager service.
+   *
+   * @var \Drupal\Core\Entity\EntityFieldManagerInterface
+   */
+  protected $entityFieldManager;
+
+  /**
+   * Constructs a new class instance.
+   *
+   * @param \Drupal\media_entity\MediaTypeManager $media_type_manager
+   *   Media type manager.
+   */
+  public function __construct(MediaTypeManager $media_type_manager, EntityFieldManagerInterface $entity_field_manager) {
+    $this->mediaTypeManager = $media_type_manager;
+    $this->entityFieldManager = $entity_field_manager;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container) {
+    return new static(
+      $container->get('plugin.manager.media_entity.type'),
+      $container->get('entity_field.manager')
+    );
+  }
+
+  /**
+   * Ajax callback triggered by the type provider select element.
+   *
+   * @param array $form
+   *   The form array.
+   * @param \Drupal\Core\Form\FormStateInterface $form_state
+   *   Current form state.
+   *
+   * @return \Drupal\Core\Ajax\AjaxResponse
+   *   The ajax response.
+   */
+  public function ajaxTypeProviderData(array $form, FormStateInterface $form_state) {
+    $response = new AjaxResponse();
+    $plugin = $this->entity->getType()->getPluginId();
+
+    $response->addCommand(new ReplaceCommand('#edit-type-configuration-plugin-wrapper', $form['type_configuration'][$plugin]));
+    $response->addCommand(new ReplaceCommand('#field-mapping-wrapper', $form['field_mapping']));
+
+    return $response;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function form(array $form, FormStateInterface $form_state) {
+    $form = parent::form($form, $form_state);
+
+    /** @var \Drupal\media_entity\MediaBundleInterface $bundle */
+    $form['#entity'] = $bundle = $this->entity;
+    $form_state->set('bundle', $bundle->id());
+
+    if ($this->operation == 'add') {
+      $form['#title'] = $this->t('Add media bundle');
+    }
+    elseif ($this->operation == 'edit') {
+      $form['#title'] = $this->t('Edit %label media bundle', ['%label' => $bundle->label()]);
+    }
+
+    $form['label'] = [
+      '#title' => $this->t('Label'),
+      '#type' => 'textfield',
+      '#default_value' => $bundle->label(),
+      '#description' => $this->t('The human-readable name of this media bundle.'),
+      '#required' => TRUE,
+      '#size' => 30,
+      '#weight' => -100,
+    ];
+
+    // @todo: '#disabled' not always FALSE.
+    $form['id'] = [
+      '#type' => 'machine_name',
+      '#default_value' => $bundle->id(),
+      '#maxlength' => 32,
+      '#disabled' => !$bundle->isNew(),
+      '#machine_name' => [
+        'exists' => ['\Drupal\media_entity\Entity\MediaBundle', 'exists'],
+        'source' => ['label'],
+      ],
+      '#description' => $this->t('A unique machine-readable name for this media bundle.'),
+      '#weight' => -90,
+    ];
+
+    $form['description'] = [
+      '#title' => $this->t('Description'),
+      '#type' => 'textarea',
+      '#default_value' => $bundle->getDescription(),
+      '#description' => $this->t('Describe this media bundle. The text will be displayed on the <em>Add new media</em> page.'),
+      '#weight' => -80,
+    ];
+
+    $plugins = $this->mediaTypeManager->getDefinitions();
+    $options = [];
+    foreach ($plugins as $plugin => $definition) {
+      $options[$plugin] = $definition['label'];
+    }
+
+    $form['type'] = [
+      '#type' => 'select',
+      '#title' => $this->t('Type provider'),
+      '#default_value' => $bundle->getType()->getPluginId(),
+      '#options' => $options,
+      '#description' => $this->t('Media type provider plugin that is responsible for additional logic related to this media.'),
+      '#weight' => -70,
+      '#ajax' => [
+        'callback' => '::ajaxTypeProviderData',
+        'progress' => [
+          'type' => 'throbber',
+          'message' => $this->t('Updating type provider configuration form.'),
+        ],
+      ],
+    ];
+
+    // Media type plugin configuration.
+    $form['type_configuration'] = [
+      '#type' => 'fieldset',
+      '#title' => $this->t('Type provider configuration'),
+      '#tree' => TRUE,
+      '#weight' => -60,
+    ];
+
+    /** @var \Drupal\media_entity\MediaTypeInterface $plugin */
+    if ($plugin = $bundle->getType()) {
+      $plugin_configuration = (empty($this->configurableInstances[$plugin->getPluginId()]['plugin_config'])) ? $bundle->type_configuration : $this->configurableInstances[$plugin->getPluginId()]['plugin_config'];
+      /** @var \Drupal\media_entity\MediaTypeBase $instance */
+      $instance = $this->mediaTypeManager->createInstance($plugin->getPluginId(), $plugin_configuration);
+      // Store the configuration for validate and submit handlers.
+      $this->configurableInstances[$plugin->getPluginId()]['plugin_config'] = $plugin_configuration;
+
+      $form['type_configuration'][$plugin->getPluginId()] = [
+        '#type' => 'container',
+        '#attributes' => [
+          'id' => 'edit-type-configuration-plugin-wrapper',
+        ],
+      ];
+      $form['type_configuration'][$plugin->getPluginId()] += $instance->buildConfigurationForm([], $form_state);
+    }
+
+    // Field mapping configuration.
+    $form['field_mapping'] = [
+      '#type' => 'fieldset',
+      '#title' => $this->t('Field mapping'),
+      '#tree' => TRUE,
+      '#attributes' => ['id' => 'field-mapping-wrapper'],
+      'description' => [
+        '#type' => 'html_tag',
+        '#tag' => 'p',
+        '#value' => $this->t('Media type plugins can provide metadata fields such as title, caption, size information, credits, ... Media entity can automatically save this metadata information to entity fields, which can be configured below. Information will only be mapped if the entity field is empty.'),
+      ],
+      '#weight' => -50,
+    ];
+
+    if (empty($plugin) || empty($plugin->providedFields())) {
+      $form['field_mapping']['empty_message'] = [
+        '#prefix' => '<em>',
+        '#suffix' => '</em>',
+        '#markup' => $this->t('No metadata fields available.'),
+      ];
+    }
+    else {
+      $skipped_fields = [
+        'mid',
+        'uuid',
+        'vid',
+        'bundle',
+        'langcode',
+        'default_langcode',
+        'uid',
+        'revision_timestamp',
+        'revision_log',
+        'revision_uid',
+      ];
+      $options = ['_none' => $this->t('- Skip field -')];
+      foreach ($this->entityFieldManager->getFieldDefinitions('media', $bundle->id()) as $field_name => $field) {
+        if (!in_array($field_name, $skipped_fields)) {
+          $options[$field_name] = $field->getLabel();
+        }
+      }
+
+      $field_map = $bundle->getFieldMap();
+      foreach ($plugin->providedFields() as $field_name => $field_label) {
+        $form['field_mapping'][$field_name] = [
+          '#type' => 'select',
+          '#title' => $field_label,
+          '#options' => $options,
+          '#default_value' => isset($field_map[$field_name]) ? $field_map[$field_name] : '_none',
+        ];
+      }
+    }
+
+    $form['additional_settings'] = [
+      '#type' => 'vertical_tabs',
+      '#attached' => [
+        'library' => ['media_entity/media_bundle_form'],
+      ],
+      '#weight' => 100,
+    ];
+
+    $form['workflow'] = [
+      '#type' => 'details',
+      '#title' => $this->t('Publishing options'),
+      '#group' => 'additional_settings',
+    ];
+
+    $workflow_options = [
+      'status' => $bundle->getStatus(),
+      'new_revision' => $bundle->shouldCreateNewRevision(),
+      'queue_thumbnail_downloads' => $bundle->getQueueThumbnailDownloads(),
+    ];
+    // Prepare workflow options to be used for 'checkboxes' form element.
+    $keys = array_keys(array_filter($workflow_options));
+    $workflow_options = array_combine($keys, $keys);
+    $form['workflow']['options'] = [
+      '#type' => 'checkboxes',
+      '#title' => $this->t('Default options'),
+      '#default_value' => $workflow_options,
+      '#options' => [
+        'status' => $this->t('Published'),
+        'new_revision' => $this->t('Create new revision'),
+        'queue_thumbnail_downloads' => $this->t('Queue thumbnail downloads'),
+      ],
+    ];
+
+    $form['workflow']['options']['status']['#description'] = $this->t('Entities will be automatically published when they are created.');
+    $form['workflow']['options']['new_revision']['#description'] = $this->t('Automatically create a new revision of media entities. Users with the Administer media permission will be able to override this option.');
+    $form['workflow']['options']['queue_thumbnail_downloads']['#description'] = $this->t('Download thumbnails via a queue.');
+
+    if ($this->moduleHandler->moduleExists('language')) {
+      $form['language'] = [
+        '#type' => 'details',
+        '#title' => $this->t('Language settings'),
+        '#group' => 'additional_settings',
+      ];
+
+      $language_configuration = ContentLanguageSettings::loadByEntityTypeBundle('media', $bundle->id());
+
+      $form['language']['language_configuration'] = [
+        '#type' => 'language_configuration',
+        '#entity_information' => [
+          'entity_type' => 'media',
+          'bundle' => $bundle->id(),
+        ],
+        '#default_value' => $language_configuration,
+      ];
+    }
+
+    return $form;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function validateForm(array &$form, FormStateInterface $form_state) {
+    parent::validateForm($form, $form_state);
+
+    // Let the selected plugin validate its settings.
+    $plugin = $this->entity->getType()->getPluginId();
+    $plugin_configuration = !empty($this->configurableInstances[$plugin]['plugin_config']) ? $this->configurableInstances[$plugin]['plugin_config'] : [];
+    $instance = $this->mediaTypeManager->createInstance($plugin, $plugin_configuration);
+    $instance->validateConfigurationForm($form, $form_state);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function submitForm(array &$form, FormStateInterface $form_state) {
+    parent::submitForm($form, $form_state);
+
+    $workflow_options = ['status', 'queue_thumbnail_downloads'];
+    foreach ($workflow_options as $option) {
+      $this->entity->$option = (bool) $form_state->getValue(['options', $option]);
+    }
+
+    $this->entity->setNewRevision((bool) $form_state->getValue(['options', 'new_revision']));
+
+    // Let the selected plugin save its settings.
+    $plugin = $this->entity->getType()->getPluginId();
+    $plugin_configuration = !empty($this->configurableInstances[$plugin]['plugin_config']) ? $this->configurableInstances[$plugin]['plugin_config'] : [];
+    $instance = $this->mediaTypeManager->createInstance($plugin, $plugin_configuration);
+    $instance->submitConfigurationForm($form, $form_state);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function actions(array $form, FormStateInterface $form_state) {
+    $actions = parent::actions($form, $form_state);
+    $actions['submit']['#value'] = $this->t('Save media bundle');
+    $actions['delete']['#value'] = $this->t('Delete media bundle');
+    $actions['delete']['#access'] = $this->entity->access('delete');
+    return $actions;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) {
+    $configuration = $form_state->getValue('type_configuration');
+
+    // Store previous plugin config.
+    $plugin = $entity->getType()->getPluginId();
+    $this->configurableInstances[$plugin]['plugin_config'] = empty($configuration[$plugin]) ? [] : $configuration[$plugin];
+
+    /** @var \Drupal\media_entity\MediaBundleInterface $entity */
+    parent::copyFormValuesToEntity($entity, $form, $form_state);
+
+    // Use type configuration for the plugin that was chosen.
+    $plugin = $entity->getType()->getPluginId();
+    $plugin_configuration = empty($configuration[$plugin]) ? [] : $configuration[$plugin];
+    $entity->set('type_configuration', $plugin_configuration);
+
+    // Save field mapping.
+    $entity->field_map = array_filter(
+      $form_state->getValue('field_mapping', []),
+      function ($item) { return $item != '_none'; }
+    );
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function save(array $form, FormStateInterface $form_state) {
+    /** @var \Drupal\media_entity\MediaBundleInterface $bundle */
+    $bundle = $this->entity;
+    $status = $bundle->save();
+
+    $t_args = ['%name' => $bundle->label()];
+    if ($status == SAVED_UPDATED) {
+      drupal_set_message($this->t('The media bundle %name has been updated.', $t_args));
+    }
+    elseif ($status == SAVED_NEW) {
+      drupal_set_message($this->t('The media bundle %name has been added.', $t_args));
+      $this->logger('media')->notice('Added bundle %name.', $t_args);
+    }
+
+    // Override the "status" base field default value, for this bundle.
+    $fields = $this->entityFieldManager->getFieldDefinitions('media', $bundle->id());
+    $media = $this->entityTypeManager->getStorage('media')->create(array('bundle' => $bundle->id()));
+    $value = (bool) $form_state->getValue(['options', 'status']);
+    if ($media->status->value != $value) {
+      $fields['status']->getConfig($bundle->id())->setDefaultValue($value)->save();
+    }
+
+    $form_state->setRedirectUrl($bundle->toUrl('collection'));
+  }
+
+}
diff --git a/core/modules/media_entity/src/MediaBundleInterface.php b/core/modules/media_entity/src/MediaBundleInterface.php
new file mode 100644
index 0000000..6a2332c
--- /dev/null
+++ b/core/modules/media_entity/src/MediaBundleInterface.php
@@ -0,0 +1,115 @@
+<?php
+
+namespace Drupal\media_entity;
+
+use Drupal\Core\Config\Entity\ConfigEntityInterface;
+
+/**
+ * Provides an interface defining a media bundle entity.
+ */
+interface MediaBundleInterface extends ConfigEntityInterface {
+
+  /**
+   * Returns the label.
+   *
+   * @param \Drupal\media_entity\MediaInterface $media
+   *   The Media entity.
+   *
+   * @return string|bool
+   *   Returns the label of the bundle that entity belongs to.
+   */
+  public static function getLabel(MediaInterface $media);
+
+  /**
+   * Checks if the bundle exists.
+   *
+   * @param int $id
+   *   The Media bundle ID.
+   *
+   * @return bool
+   *   TRUE if the bundle with the given ID exists, FALSE otherwise.
+   */
+  public static function exists($id);
+
+  /**
+   * Returns whether thumbnail downloads are queued.
+   *
+   * @return bool
+   *   Returns download now or later.
+   */
+  public function getQueueThumbnailDownloads();
+
+  /**
+   * Sets a flag to indicate that thumbnails should be downloaded via a queue.
+   *
+   * @param bool $queue_thumbnail_downloads
+   *   The queue downloads flag.
+   */
+  public function setQueueThumbnailDownloads($queue_thumbnail_downloads);
+
+  /**
+   * Returns the Media bundle description.
+   *
+   * @return string
+   *   Returns the Media bundle description.
+   */
+  public function getDescription();
+
+  /**
+   * Returns the media type plugin.
+   *
+   * @return \Drupal\media_entity\MediaTypeInterface
+   *   The type.
+   */
+  public function getType();
+
+  /**
+   * Returns the media type configuration.
+   *
+   * @return array
+   *   The type configuration.
+   */
+  public function getTypeConfiguration();
+
+  /**
+   * Sets the media type configuration.
+   *
+   * @param array $configuration
+   *   The type configuration.
+   */
+  public function setTypeConfiguration($configuration);
+
+  /**
+   * Returns the media type status.
+   *
+   * @return bool
+   *   The status.
+   */
+  public function getStatus();
+
+  /**
+   * Gets whether a new revision should be created by default.
+   *
+   * @return bool
+   *   TRUE if a new revision should be created by default.
+   */
+  public function shouldCreateNewRevision();
+
+  /**
+   * Sets whether a new revision should be created by default.
+   *
+   * @param bool $new_revision
+   *   TRUE if a new revision should be created by default.
+   */
+  public function setNewRevision($new_revision);
+
+  /**
+   * Returns the metadata field map.
+   *
+   * @return array
+   *   Field mapping array with fields provided by the type plugin as keys and
+   *   Drupal Entity fields as values.
+   */
+  public function getFieldMap();
+
+}
diff --git a/core/modules/media_entity/src/MediaBundleListBuilder.php b/core/modules/media_entity/src/MediaBundleListBuilder.php
new file mode 100644
index 0000000..e5158b1
--- /dev/null
+++ b/core/modules/media_entity/src/MediaBundleListBuilder.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace Drupal\media_entity;
+
+use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
+use Drupal\Core\Entity\EntityHandlerInterface;
+use Drupal\Core\Entity\EntityInterface;
+use Drupal\Component\Utility\Xss;
+use Drupal\Core\Url;
+
+/**
+ * Provides a listing of media bundles.
+ */
+class MediaBundleListBuilder extends ConfigEntityListBuilder implements EntityHandlerInterface {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildHeader() {
+    $header['title'] = $this->t('Name');
+    $header['description'] = [
+      'data' => $this->t('Description'),
+      'class' => [RESPONSIVE_PRIORITY_MEDIUM],
+    ];
+    return $header + parent::buildHeader();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildRow(EntityInterface $entity) {
+    $row['title'] = [
+      'data' => $entity->label(),
+      'class' => ['menu-label'],
+    ];
+    $row['description'] = Xss::filterAdmin($entity->getDescription());
+    return $row + parent::buildRow($entity);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function render() {
+    $build = parent::render();
+    $build['#empty'] = $this->t('No media bundle available. <a href="@link">Add media bundle</a>.', [
+      '@link' => Url::fromRoute('entity.media_bundle.add_form')->toString(),
+    ]);
+    return $build;
+  }
+
+}
diff --git a/core/modules/media_entity/src/MediaForm.php b/core/modules/media_entity/src/MediaForm.php
new file mode 100644
index 0000000..b728fad
--- /dev/null
+++ b/core/modules/media_entity/src/MediaForm.php
@@ -0,0 +1,238 @@
+<?php
+
+namespace Drupal\media_entity;
+
+use Drupal\Core\Entity\ContentEntityForm;
+use Drupal\Core\Form\FormStateInterface;
+
+/**
+ * Form controller for the media edit forms.
+ */
+class MediaForm extends ContentEntityForm {
+
+  /**
+   * Default settings for this media bundle.
+   *
+   * @var array
+   */
+  protected $settings;
+
+  /**
+   * The entity being used by this form.
+   *
+   * @var \Drupal\media_entity\Entity\Media
+   */
+  protected $entity;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function prepareEntity() {
+    parent::prepareEntity();
+
+    // Set up default values, if required.
+    if (!$this->entity->isNew()) {
+      $this->entity->setRevisionLogMessage(NULL);
+      $this->entity->setPublisherId($this->currentUser()->id());
+      $this->entity->setCreatedTime(\Drupal::time()->getRequestTime());
+    }
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function form(array $form, FormStateInterface $form_state) {
+    $form = parent::form($form, $form_state);
+    $entity_type = $this->entity->getEntityType();
+    /** @var \Drupal\media_entity\Entity\MediaBundle $bundle_entity */
+    $bundle_entity = $this->entity->bundle->entity;
+    $account = $this->currentUser();
+    $new_revision = $this->entity->bundle->entity->shouldCreateNewRevision();
+
+    if ($this->operation == 'edit') {
+      $form['#title'] = $this->t('Edit %bundle_label @label', [
+        '%bundle_label' => $bundle_entity->label(),
+        '@label' => $this->entity->label(),
+      ]);
+    }
+
+    $form['advanced'] = [
+      '#type' => 'vertical_tabs',
+      '#weight' => 99,
+    ];
+
+    // Add a log field if the "Create new revision" option is checked, or if the
+    // current user has the ability to check that option.
+    $form['revision_information'] = [
+      '#type' => 'details',
+      '#title' => $this->t('Revision information'),
+      // Open by default when "Create new revision" is checked.
+      '#open' => $new_revision,
+      '#group' => 'advanced',
+      '#weight' => 20,
+      '#access' => $new_revision || $account->hasPermission($entity_type->get('admin_permission')),
+      '#attributes' => [
+        'class' => ['media-form-revision-information'],
+      ],
+    ];
+
+    $form['revision_information']['revision'] = [
+      '#type' => 'checkbox',
+      '#title' => $this->t('Create new revision'),
+      '#default_value' => $new_revision,
+      '#access' => $account->hasPermission($entity_type->get('admin_permission')),
+    ];
+
+    // Check the revision log checkbox when the log textarea is filled in.
+    // This must not happen if "Create new revision" is enabled by default,
+    // since the state would auto-disable the checkbox otherwise.
+    if (!$new_revision) {
+      $form['revision_information']['revision']['#states'] = [
+        'checked' => [
+          'textarea[name="revision_log"]' => ['empty' => FALSE],
+        ],
+      ];
+    }
+
+    $form['revision_information']['revision_log'] = [
+      '#type' => 'textarea',
+      '#title' => $this->t('Revision log message'),
+      '#rows' => 4,
+      '#default_value' => $this->entity->getRevisionLogMessage(),
+      '#description' => $this->t('Briefly describe the changes you have made.'),
+    ];
+
+    // Media author information for administrators.
+    if (isset($form['uid']) || isset($form['created'])) {
+      $form['author'] = [
+        '#type' => 'details',
+        '#title' => $this->t('Authoring information'),
+        '#group' => 'advanced',
+        '#attributes' => [
+          'class' => ['media-form-author'],
+        ],
+        '#weight' => 90,
+        '#optional' => TRUE,
+      ];
+    }
+
+    if (isset($form['uid'])) {
+      $form['uid']['#group'] = 'author';
+    }
+
+    if (isset($form['created'])) {
+      $form['created']['#group'] = 'author';
+    }
+
+    $form['#attached']['library'][] = 'media_entity/media_form';
+
+    $form['#entity_builders']['update_status'] = [$this, 'updateStatus'];
+
+    return $form;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function actions(array $form, FormStateInterface $form_state) {
+    $element = parent::actions($form, $form_state);
+    $media = $this->entity;
+
+    // Add a "Publish" button.
+    $element['publish'] = $element['submit'];
+    // If the "Publish" button is clicked, we want to update the status to
+    // "published".
+    $element['publish']['#published_status'] = TRUE;
+    $element['publish']['#dropbutton'] = 'save';
+    if ($media->isNew()) {
+      $element['publish']['#value'] = $this->t('Save and publish');
+    }
+    else {
+      $element['publish']['#value'] = $media->isPublished() ? $this->t('Save and keep published') : $this->t('Save and publish');
+    }
+    $element['publish']['#weight'] = 0;
+
+    // Add a "Unpublish" button.
+    $element['unpublish'] = $element['submit'];
+    // If the "Unpublish" button is clicked, we want to update the status to
+    // "unpublished".
+    $element['unpublish']['#published_status'] = FALSE;
+    $element['unpublish']['#dropbutton'] = 'save';
+    if ($media->isNew()) {
+      $element['unpublish']['#value'] = $this->t('Save as unpublished');
+    }
+    else {
+      $element['unpublish']['#value'] = !$media->isPublished() ? $this->t('Save and keep unpublished') : $this->t('Save and unpublish');
+    }
+    $element['unpublish']['#weight'] = 10;
+
+    // If already published, the 'publish' button is primary.
+    if ($media->isPublished()) {
+      unset($element['unpublish']['#button_type']);
+    }
+    // Otherwise, the 'unpublish' button is primary and should come first.
+    else {
+      unset($element['publish']['#button_type']);
+      $element['unpublish']['#weight'] = -10;
+    }
+
+    // Remove the "Save" button.
+    $element['submit']['#access'] = FALSE;
+
+    $element['delete']['#access'] = $media->access('delete');
+    $element['delete']['#weight'] = 100;
+
+    return $element;
+  }
+
+  /**
+   * Entity builder updating the media status with the submitted value.
+   *
+   * @param string $entity_type_id
+   *   The entity type identifier.
+   * @param \Drupal\media_entity\MediaInterface $media
+   *   The media updated with the submitted values.
+   * @param array $form
+   *   The complete form array.
+   * @param \Drupal\Core\Form\FormStateInterface $form_state
+   *   The current state of the form.
+   *
+   * @see \Drupal\media\MediaForm::form()
+   */
+  public function updateStatus($entity_type_id, MediaInterface $media, array $form, FormStateInterface $form_state) {
+    $element = $form_state->getTriggeringElement();
+    if (isset($element['#published_status'])) {
+      $media->setPublished($element['#published_status']);
+    }
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function save(array $form, FormStateInterface $form_state) {
+    // Save as a new revision if requested to do so.
+    if (!$form_state->isValueEmpty('revision')) {
+      $this->entity->setNewRevision();
+    }
+
+    $insert = $this->entity->isNew();
+    $this->entity->save();
+    $context = ['@type' => $this->entity->bundle(), '%info' => $this->entity->label()];
+    $logger = $this->logger($this->entity->id());
+    $t_args = ['@type' => $this->entity->bundle->entity->label(), '%info' => $this->entity->label()];
+
+    if ($insert) {
+      $logger->notice('@type: added %info.', $context);
+      drupal_set_message($this->t('@type %info has been created.', $t_args));
+    }
+    else {
+      $logger->notice('@type: updated %info.', $context);
+      drupal_set_message($this->t('@type %info has been updated.', $t_args));
+    }
+
+    $form_state->setValue('id', $this->entity->id());
+    $form_state->set('id', $this->entity->id());
+    $form_state->setRedirectUrl($this->entity->toUrl('canonical'));
+  }
+
+}
diff --git a/core/modules/media_entity/src/MediaInterface.php b/core/modules/media_entity/src/MediaInterface.php
new file mode 100644
index 0000000..23513fc
--- /dev/null
+++ b/core/modules/media_entity/src/MediaInterface.php
@@ -0,0 +1,107 @@
+<?php
+
+namespace Drupal\media_entity;
+
+use Drupal\Core\Entity\EntityChangedInterface;
+use Drupal\Core\Entity\ContentEntityInterface;
+use Drupal\Core\Entity\RevisionLogInterface;
+use Drupal\user\EntityOwnerInterface;
+
+/**
+ * Provides an interface defining a media entity.
+ */
+interface MediaInterface extends ContentEntityInterface, EntityChangedInterface, RevisionLogInterface, EntityOwnerInterface {
+
+  /**
+   * Returns the media creation timestamp.
+   *
+   * @return int
+   *   Creation timestamp of the media.
+   */
+  public function getCreatedTime();
+
+  /**
+   * Sets the media creation timestamp.
+   *
+   * @param int $timestamp
+   *   The media creation timestamp.
+   *
+   * @return \Drupal\media_entity\MediaInterface
+   *   The called media entity.
+   */
+  public function setCreatedTime($timestamp);
+
+  /**
+   * Returns the media publisher user entity.
+   *
+   * @return \Drupal\user\UserInterface
+   *   The author user entity.
+   *
+   * @deprecated in Drupal 8.3.0, will be removed before Drupal 9.0.0. Use
+   *   \Drupal\user\EntityOwnerInterface::getOwner() instead.
+   */
+  public function getPublisher();
+
+  /**
+   * Returns the media publisher user ID.
+   *
+   * @return int
+   *   The author user ID.
+   *
+   * @deprecated in Drupal 8.3.0, will be removed before Drupal 9.0.0. Use
+   *   \Drupal\user\EntityOwnerInterface::getOwnerId() instead.
+   */
+  public function getPublisherId();
+
+  /**
+   * Sets the media publisher user ID.
+   *
+   * @param int $uid
+   *   The author user id.
+   *
+   * @return \Drupal\media_entity\MediaInterface
+   *   The called media entity.
+   *
+   * @deprecated in Drupal 8.3.0, will be removed before Drupal 9.0.0. Use
+   *   \Drupal\user\EntityOwnerInterface::setOwnerId() instead.
+   */
+  public function setPublisherId($uid);
+
+  /**
+   * Returns the media published status indicator.
+   *
+   * Unpublished media are only visible to their authors and to administrators.
+   *
+   * @return bool
+   *   TRUE if the media is published.
+   */
+  public function isPublished();
+
+  /**
+   * Sets the published status of a media.
+   *
+   * @param bool $published
+   *   TRUE to set this media to published, FALSE to set it to unpublished.
+   *
+   * @return \Drupal\media_entity\MediaInterface
+   *   The called media entity.
+   */
+  public function setPublished($published);
+
+  /**
+   * Returns the media type.
+   *
+   * @return \Drupal\media_entity\MediaTypeInterface
+   *   The media type.
+   */
+  public function getType();
+
+  /**
+   * Automatically determines the most appropriate thumbnail.
+   *
+   * Determines (with help of type plugin) the thumbnail image and sets the
+   * value of the thumbnail base field.
+   */
+  public function automaticallySetThumbnail();
+
+}
diff --git a/core/modules/media_entity/src/MediaTypeBase.php b/core/modules/media_entity/src/MediaTypeBase.php
new file mode 100644
index 0000000..68b1940
--- /dev/null
+++ b/core/modules/media_entity/src/MediaTypeBase.php
@@ -0,0 +1,160 @@
+<?php
+
+namespace Drupal\media_entity;
+
+use Drupal\Core\Config\ConfigFactoryInterface;
+use Drupal\Core\Plugin\PluginBase;
+use Drupal\Core\Config\Config;
+use Drupal\Core\Entity\EntityFieldManagerInterface;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
+use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+use Drupal\Component\Utility\NestedArray;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+use Drupal\Core\Form\FormStateInterface;
+
+/**
+ * Base implementation of media type plugin.
+ */
+abstract class MediaTypeBase extends PluginBase implements MediaTypeInterface, ContainerFactoryPluginInterface {
+
+  /**
+   * Plugin label.
+   *
+   * @var string
+   */
+  protected $label;
+
+  /**
+   * The entity type manager service.
+   *
+   * @var \Drupal\Core\Entity\EntityTypeManagerInterface;
+   */
+  protected $entityTypeManager;
+
+  /**
+   * The entity field manager service.
+   *
+   * @var \Drupal\Core\Entity\EntityFieldManagerInterface;
+   */
+  protected $entityFieldManager;
+
+  /**
+   * The config factory service.
+   *
+   * @var \Drupal\Core\Config\ConfigFactoryInterface
+   */
+  protected $configFactory;
+
+  /**
+   * Constructs a new class instance.
+   *
+   * @param array $configuration
+   *   A configuration array containing information about the plugin instance.
+   * @param string $plugin_id
+   *   The plugin_id for the plugin instance.
+   * @param mixed $plugin_definition
+   *   The plugin implementation definition.
+   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
+   *   Entity type manager service.
+   * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
+   *   Entity field manager service.
+   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
+   *   The config factory service.
+   */
+  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, ConfigFactoryInterface $config_factory) {
+    parent::__construct($configuration, $plugin_id, $plugin_definition);
+    $this->entityTypeManager = $entity_type_manager;
+    $this->entityFieldManager = $entity_field_manager;
+    $this->configFactory = $config_factory;
+    $this->setConfiguration($configuration);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+    return new static(
+      $configuration,
+      $plugin_id,
+      $plugin_definition,
+      $container->get('entity_type.manager'),
+      $container->get('entity_field.manager'),
+      $container->get('config.factory')
+    );
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setConfiguration(array $configuration) {
+    $this->configuration = NestedArray::mergeDeep(
+      $this->defaultConfiguration(),
+      $configuration
+    );
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getConfiguration() {
+    return $this->configuration;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function defaultConfiguration() {
+    return [];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getDefaultThumbnail() {
+    return '';
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function label() {
+    return $this->label;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function attachConstraints(MediaInterface $media) {}
+
+  /**
+   * {@inheritdoc}
+   */
+  public function calculateDependencies() {
+    return [];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
+    return [];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {}
+
+  /**
+   * {@inheritdoc}
+   */
+  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {}
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getDefaultName(MediaInterface $media) {
+    return 'media:' . $media->bundle() . ':' . $media->uuid();
+  }
+
+}
diff --git a/core/modules/media_entity/src/MediaTypeException.php b/core/modules/media_entity/src/MediaTypeException.php
new file mode 100644
index 0000000..9e3ac2c
--- /dev/null
+++ b/core/modules/media_entity/src/MediaTypeException.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace Drupal\media_entity;
+
+/**
+ * Generic Plugin exception class to be thrown when no more specific class
+ * is applicable.
+ */
+class MediaTypeException extends \Exception {
+
+  /**
+   * Form element name that this exception belongs to.
+   *
+   * @var string
+   */
+  protected $element;
+
+  /**
+   * Construct the exception.
+   *
+   * @param string $element
+   *   [optional] Name of form element that exception refers to.
+   * @param string $message
+   *   [optional] The Exception message to throw.
+   * @param int $code
+   *   [optional] The Exception code.
+   * @param \Exception $previous
+   *   [optional] The previous exception used for the exception chaining.
+   */
+  public function __construct($element = NULL, $message = "", $code = 0, \Exception $previous = NULL) {
+    parent::__construct($message, $code, $previous);
+    $this->element = $element;
+  }
+
+  /**
+   * Gets element.
+   *
+   * @return string
+   *   Element name.
+   */
+  public function getElement() {
+    return $this->element;
+  }
+
+}
diff --git a/core/modules/media_entity/src/MediaTypeInterface.php b/core/modules/media_entity/src/MediaTypeInterface.php
new file mode 100644
index 0000000..2a171c2
--- /dev/null
+++ b/core/modules/media_entity/src/MediaTypeInterface.php
@@ -0,0 +1,88 @@
+<?php
+
+namespace Drupal\media_entity;
+
+use Drupal\Component\Plugin\PluginInspectionInterface;
+use Drupal\Component\Plugin\ConfigurablePluginInterface;
+use Drupal\Core\Plugin\PluginFormInterface;
+
+/**
+ * Defines the interface for media types.
+ */
+interface MediaTypeInterface extends PluginInspectionInterface, ConfigurablePluginInterface, PluginFormInterface {
+
+  /**
+   * Returns the display label.
+   *
+   * @return string
+   *   The display label.
+   */
+  public function label();
+
+  /**
+   * Gets list of fields provided by this plugin.
+   *
+   * @return array
+   *   Associative array with field names as keys and descriptions as values.
+   */
+  public function providedFields();
+
+  /**
+   * Gets a media-related field/value.
+   *
+   * @param MediaInterface $media
+   *   Media object.
+   * @param string $name
+   *   Name of field to fetch.
+   *
+   * @return mixed
+   *   Field value or FALSE if data unavailable.
+   */
+  public function getField(MediaInterface $media, $name);
+
+  /**
+   * Attaches type-specific constraints to media.
+   *
+   * @param MediaInterface $media
+   *   Media entity.
+   */
+  public function attachConstraints(MediaInterface $media);
+
+  /**
+   * Gets thumbnail image.
+   *
+   * Media type plugin is responsible for returning URI of the generic thumbnail
+   * if no other is available. This functions should always return a valid URI.
+   *
+   * @param MediaInterface $media
+   *   Media.
+   *
+   * @return string
+   *   URI of the thumbnail.
+   */
+  public function thumbnail(MediaInterface $media);
+
+  /**
+   * Gets the default thumbnail image.
+   *
+   * @return string
+   *   Uri of the default thumbnail image.
+   */
+  public function getDefaultThumbnail();
+
+  /**
+   * Provide a default name for the media.
+   *
+   * Plugins defining media bundles are suggested to override this method and
+   * provide a default name, to be used when there is no user-defined label
+   * available.
+   *
+   * @param \Drupal\media_entity\MediaInterface $media
+   *   The media object.
+   *
+   * @return string
+   *   The string that should be used as default media name.
+   */
+  public function getDefaultName(MediaInterface $media);
+
+}
diff --git a/core/modules/media_entity/src/MediaTypeManager.php b/core/modules/media_entity/src/MediaTypeManager.php
new file mode 100644
index 0000000..5ec95cc
--- /dev/null
+++ b/core/modules/media_entity/src/MediaTypeManager.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace Drupal\media_entity;
+
+use Drupal\Core\Cache\CacheBackendInterface;
+use Drupal\Core\Extension\ModuleHandlerInterface;
+use Drupal\Core\Plugin\DefaultPluginManager;
+
+/**
+ * Manages media entity type plugins.
+ */
+class MediaTypeManager extends DefaultPluginManager {
+
+  /**
+   * Constructs a new MediaTypeManager.
+   *
+   * @param \Traversable $namespaces
+   *   An object that implements \Traversable which contains the root paths
+   *   keyed by the corresponding namespace to look for plugin implementations.
+   * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
+   *   Cache backend instance to use.
+   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
+   *   The module handler.
+   */
+  public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
+    parent::__construct('Plugin/MediaEntity/Type', $namespaces, $module_handler, 'Drupal\media_entity\MediaTypeInterface', 'Drupal\media_entity\Annotation\MediaType');
+
+    $this->alterInfo('media_entity_type_info');
+    $this->setCacheBackend($cache_backend, 'media_entity_type_plugins');
+  }
+
+}
diff --git a/core/modules/media_entity/src/MediaViewsData.php b/core/modules/media_entity/src/MediaViewsData.php
new file mode 100644
index 0000000..f1a4e6f
--- /dev/null
+++ b/core/modules/media_entity/src/MediaViewsData.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace Drupal\media_entity;
+
+use Drupal\views\EntityViewsData;
+
+/**
+ * Provides the views data for the media entity type.
+ */
+class MediaViewsData extends EntityViewsData {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getViewsData() {
+    $data = parent::getViewsData();
+
+    $data['media_field_data']['table']['wizard_id'] = 'media';
+    $data['media_field_revision']['table']['wizard_id'] = 'media_revision';
+
+    return $data;
+  }
+
+}
diff --git a/core/modules/media_entity/src/Plugin/Action/DeleteMedia.php b/core/modules/media_entity/src/Plugin/Action/DeleteMedia.php
new file mode 100644
index 0000000..b2a98d2
--- /dev/null
+++ b/core/modules/media_entity/src/Plugin/Action/DeleteMedia.php
@@ -0,0 +1,98 @@
+<?php
+
+namespace Drupal\media_entity\Plugin\Action;
+
+use Drupal\Core\Action\ActionBase;
+use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+use Drupal\Core\Session\AccountInterface;
+use Drupal\user\PrivateTempStoreFactory;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * Redirects to a media deletion form.
+ *
+ * @Action(
+ *   id = "media_delete_action",
+ *   label = @Translation("Delete media"),
+ *   type = "media",
+ *   confirm_form_route_name = "entity.media.multiple_delete_confirm"
+ * )
+ */
+class DeleteMedia extends ActionBase implements ContainerFactoryPluginInterface {
+
+  /**
+   * The tempstore object.
+   *
+   * @var \Drupal\user\SharedTempStore
+   */
+  protected $tempStore;
+
+  /**
+   * The current user.
+   *
+   * @var \Drupal\Core\Session\AccountInterface
+   */
+  protected $currentUser;
+
+  /**
+   * Constructs a new DeleteMedia object.
+   *
+   * @param array $configuration
+   *   A configuration array containing information about the plugin instance.
+   * @param string $plugin_id
+   *   The plugin ID for the plugin instance.
+   * @param mixed $plugin_definition
+   *   The plugin implementation definition.
+   * @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory
+   *   The tempstore factory.
+   * @param AccountInterface $current_user
+   *   Current user.
+   */
+  public function __construct(array $configuration, $plugin_id, $plugin_definition, PrivateTempStoreFactory $temp_store_factory, AccountInterface $current_user) {
+    parent::__construct($configuration, $plugin_id, $plugin_definition);
+    $this->currentUser = $current_user;
+    $this->tempStore = $temp_store_factory->get('media_multiple_delete_confirm');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+    return new static(
+      $configuration,
+      $plugin_id,
+      $plugin_definition,
+      $container->get('user.private_tempstore'),
+      $container->get('current_user')
+    );
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function executeMultiple(array $entities) {
+    $info = [];
+    /** @var \Drupal\media_entity\MediaInterface $media */
+    foreach ($entities as $media) {
+      $langcode = $media->language()->getId();
+      $info[$media->id()][$langcode] = $langcode;
+    }
+    $this->tempStore->set($this->currentUser->id(), $info);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function execute($object = NULL) {
+    $this->executeMultiple(array($object));
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
+    /** @var \Drupal\media_entity\MediaInterface $object */
+    return $object->access('delete', $account, $return_as_object);
+  }
+
+}
diff --git a/core/modules/media_entity/src/Plugin/Action/PublishMedia.php b/core/modules/media_entity/src/Plugin/Action/PublishMedia.php
new file mode 100644
index 0000000..d223bab
--- /dev/null
+++ b/core/modules/media_entity/src/Plugin/Action/PublishMedia.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace Drupal\media_entity\Plugin\Action;
+
+use Drupal\Core\Action\ActionBase;
+use Drupal\Core\Session\AccountInterface;
+use Drupal\media_entity\Entity\Media;
+
+/**
+ * Publishes a media entity.
+ *
+ * @Action(
+ *   id = "media_publish_action",
+ *   label = @Translation("Publish media"),
+ *   type = "media"
+ * )
+ */
+class PublishMedia extends ActionBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function execute(Media $entity = NULL) {
+    $entity->setPublished(TRUE)->save();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
+    /** @var \Drupal\media_entity\MediaInterface $object */
+    $result = $object->access('update', $account, TRUE)
+      ->andIf($object->status->access('edit', $account, TRUE));
+
+    return $return_as_object ? $result : $result->isAllowed();
+  }
+
+}
diff --git a/core/modules/media_entity/src/Plugin/Action/SaveMedia.php b/core/modules/media_entity/src/Plugin/Action/SaveMedia.php
new file mode 100644
index 0000000..a061cfc
--- /dev/null
+++ b/core/modules/media_entity/src/Plugin/Action/SaveMedia.php
@@ -0,0 +1,37 @@
+<?php
+
+namespace Drupal\media_entity\Plugin\Action;
+
+use Drupal\Core\Action\ActionBase;
+use Drupal\Core\Session\AccountInterface;
+
+/**
+ * Provides an action that can save any entity.
+ *
+ * @Action(
+ *   id = "media_save_action",
+ *   label = @Translation("Save media"),
+ *   type = "media"
+ * )
+ */
+class SaveMedia extends ActionBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function execute($entity = NULL) {
+    // We need to change at least one value, otherwise the changed timestamp
+    // will not be updated.
+    $entity->changed = 0;
+    $entity->save();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
+    /** @var \Drupal\media_entity\MediaInterface $object */
+    return $object->access('update', $account, $return_as_object);
+  }
+
+}
diff --git a/core/modules/media_entity/src/Plugin/Action/UnpublishMedia.php b/core/modules/media_entity/src/Plugin/Action/UnpublishMedia.php
new file mode 100644
index 0000000..59e4d2f
--- /dev/null
+++ b/core/modules/media_entity/src/Plugin/Action/UnpublishMedia.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace Drupal\media_entity\Plugin\Action;
+
+use Drupal\Core\Action\ActionBase;
+use Drupal\Core\Session\AccountInterface;
+use Drupal\media_entity\Entity\Media;
+
+/**
+ * Unpublishes a media entity.
+ *
+ * @Action(
+ *   id = "media_unpublish_action",
+ *   label = @Translation("Unpublish media"),
+ *   type = "media"
+ * )
+ */
+class UnpublishMedia extends ActionBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function execute(Media $entity = NULL) {
+    $entity->setPublished(FALSE)->save();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
+    /** @var \Drupal\media_entity\MediaInterface $object */
+    $result = $object->access('update', $account, TRUE)
+      ->andIf($object->status->access('edit', $account, TRUE));
+
+    return $return_as_object ? $result : $result->isAllowed();
+  }
+
+}
diff --git a/core/modules/media_entity/src/Plugin/Field/FieldFormatter/MediaThumbnailFormatter.php b/core/modules/media_entity/src/Plugin/Field/FieldFormatter/MediaThumbnailFormatter.php
new file mode 100644
index 0000000..a94d121
--- /dev/null
+++ b/core/modules/media_entity/src/Plugin/Field/FieldFormatter/MediaThumbnailFormatter.php
@@ -0,0 +1,188 @@
+<?php
+
+namespace Drupal\media_entity\Plugin\Field\FieldFormatter;
+
+use Drupal\Core\Field\FieldItemListInterface;
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Session\AccountInterface;
+use Drupal\image\Plugin\Field\FieldFormatter\ImageFormatter;
+use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
+use Drupal\Core\Render\RendererInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Entity\EntityStorageInterface;
+
+/**
+ * Plugin implementation of the 'media_thumbnail' formatter.
+ *
+ * @FieldFormatter(
+ *   id = "media_thumbnail",
+ *   label = @Translation("Thumbnail"),
+ *   field_types = {
+ *     "entity_reference"
+ *   }
+ * )
+ */
+class MediaThumbnailFormatter extends ImageFormatter {
+
+  /**
+   * The renderer service.
+   *
+   * @var \Drupal\Core\Render\RendererInterface
+   */
+  protected $renderer;
+
+  /**
+   * Constructs an ImageFormatter object.
+   *
+   * @param string $plugin_id
+   *   The plugin_id for the formatter.
+   * @param mixed $plugin_definition
+   *   The plugin implementation definition.
+   * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
+   *   The definition of the field to which the formatter is associated.
+   * @param array $settings
+   *   The formatter settings.
+   * @param string $label
+   *   The formatter label display setting.
+   * @param string $view_mode
+   *   The view mode.
+   * @param array $third_party_settings
+   *   Any third party settings settings.
+   * @param \Drupal\Core\Session\AccountInterface $current_user
+   *   The current user.
+   * @param \Drupal\Core\Render\RendererInterface $renderer
+   *   The renderer service.
+   */
+  public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, AccountInterface $current_user, EntityStorageInterface $image_style_storage, RendererInterface $renderer) {
+    parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings, $current_user, $image_style_storage);
+    $this->renderer = $renderer;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+    return new static(
+      $plugin_id,
+      $plugin_definition,
+      $configuration['field_definition'],
+      $configuration['settings'],
+      $configuration['label'],
+      $configuration['view_mode'],
+      $configuration['third_party_settings'],
+      $container->get('current_user'),
+      $container->get('entity.manager')->getStorage('image_style'),
+      $container->get('renderer')
+    );
+  }
+
+  /**
+   * {@inheritdoc}
+   *
+   * This has to be overriden because FileFormatterBase expects $item to be
+   * of type \Drupal\file\Plugin\Field\FieldType\FileItem and calls
+   * isDisplayed() which is not in FieldItemInterface.
+   */
+  protected function needsEntityLoad(EntityReferenceItem $item) {
+    return !$item->hasNewEntity();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function settingsForm(array $form, FormStateInterface $form_state) {
+    $element = parent::settingsForm($form, $form_state);
+
+    $link_types = [
+      'content' => $this->t('Content'),
+      'media' => $this->t('Media entity'),
+    ];
+    $element['image_link']['#options'] = $link_types;
+
+    return $element;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function settingsSummary() {
+    $summary = parent::settingsSummary();
+
+    $link_types = [
+      'content' => $this->t('Linked to content'),
+      'media' => $this->t('Linked to media entity'),
+    ];
+    // Display this setting only if image is linked.
+    $image_link_setting = $this->getSetting('image_link');
+    if (isset($link_types[$image_link_setting])) {
+      $summary[] = $link_types[$image_link_setting];
+    }
+
+    return $summary;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function viewElements(FieldItemListInterface $items, $langcode) {
+    $elements = [];
+    $media = $this->getEntitiesToView($items, $langcode);
+
+    // Early opt-out if the field is empty.
+    if (empty($media)) {
+      return $elements;
+    }
+
+    $url = NULL;
+    $image_link_setting = $this->getSetting('image_link');
+    // Check if the formatter involves a link.
+    if ($image_link_setting == 'content') {
+      $entity = $items->getEntity();
+      if (!$entity->isNew()) {
+        $url = $entity->toUrl();
+      }
+    }
+    elseif ($image_link_setting == 'media') {
+      $link_media = TRUE;
+    }
+
+    $image_style_setting = $this->getSetting('image_style');
+
+    /** @var \Drupal\media_entity\MediaInterface $media_item */
+    foreach ($media as $delta => $media_item) {
+      if (isset($link_media)) {
+        $url = $media_item->toUrl();
+      }
+
+      $elements[$delta] = [
+        '#theme' => 'image_formatter',
+        '#item' => $media_item->get('thumbnail'),
+        '#item_attributes' => [],
+        '#image_style' => $image_style_setting,
+        '#url' => $url,
+      ];
+
+      // Collect cache tags to be added for each item in the field.
+      $this->renderer->addCacheableDependency($elements[$delta], $media_item);
+    }
+
+    // Collect cache tags related to the image style setting.
+    if ($image_link_setting && ($image_style = $this->imageStyleStorage->load($image_style_setting))) {
+      $this->renderer->addCacheableDependency($elements, $image_style);
+    }
+
+    return $elements;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function isApplicable(FieldDefinitionInterface $field_definition) {
+    // This formatter is only available for entity types that reference
+    // media entities.
+    $target_type = $field_definition->getFieldStorageDefinition()->getSetting('target_type');
+    return $target_type == 'media';
+  }
+
+}
diff --git a/core/modules/media_entity/src/Plugin/MediaEntity/Type/Generic.php b/core/modules/media_entity/src/Plugin/MediaEntity/Type/Generic.php
new file mode 100644
index 0000000..3a3b40c
--- /dev/null
+++ b/core/modules/media_entity/src/Plugin/MediaEntity/Type/Generic.php
@@ -0,0 +1,53 @@
+<?php
+
+namespace Drupal\media_entity\Plugin\MediaEntity\Type;
+
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\media_entity\MediaInterface;
+use Drupal\media_entity\MediaTypeBase;
+
+/**
+ * Provides generic media type.
+ *
+ * @MediaType(
+ *   id = "generic",
+ *   label = @Translation("Generic media"),
+ *   description = @Translation("Generic media type.")
+ * )
+ */
+class Generic extends MediaTypeBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function providedFields() {
+    return [];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getField(MediaInterface $media, $name) {
+    return FALSE;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function thumbnail(MediaInterface $media) {
+    return $this->configFactory->get('media_entity.settings')->get('icon_base') . '/generic.png';
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
+    $form['text'] = [
+      '#type' => 'markup',
+      '#markup' => $this->t("This type provider doesn't need configuration."),
+    ];
+
+    return $form;
+  }
+
+}
diff --git a/core/modules/media_entity/src/Plugin/QueueWorker/thumbnailDownloader.php b/core/modules/media_entity/src/Plugin/QueueWorker/thumbnailDownloader.php
new file mode 100644
index 0000000..165f6ab
--- /dev/null
+++ b/core/modules/media_entity/src/Plugin/QueueWorker/thumbnailDownloader.php
@@ -0,0 +1,30 @@
+<?php
+
+namespace Drupal\media_entity\Plugin\QueueWorker;
+
+use Drupal\media_entity\Entity\Media;
+use Drupal\Core\Queue\QueueWorkerBase;
+
+/**
+ * Download images.
+ *
+ * @QueueWorker(
+ *   id = "media_entity_thumbnail",
+ *   title = @Translation("Thumbnail downloader"),
+ *   cron = {"time" = 60}
+ * )
+ */
+class ThumbnailDownloader extends QueueWorkerBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function processItem($data) {
+    /** @var \Drupal\media_entity\MediaInterface $entity */
+    if ($entity = Media::load($data['id'])) {
+      $entity->automaticallySetThumbnail();
+      $entity->save();
+    }
+  }
+
+}
diff --git a/core/modules/media_entity/src/Plugin/views/wizard/Media.php b/core/modules/media_entity/src/Plugin/views/wizard/Media.php
new file mode 100644
index 0000000..3a2d9da
--- /dev/null
+++ b/core/modules/media_entity/src/Plugin/views/wizard/Media.php
@@ -0,0 +1,84 @@
+<?php
+
+namespace Drupal\media_entity\Plugin\views\wizard;
+
+use Drupal\views\Plugin\views\wizard\WizardPluginBase;
+
+/**
+ * Tests creating media views with the wizard.
+ *
+ * @ViewsWizard(
+ *   id = "media",
+ *   base_table = "media_field_data",
+ *   title = @Translation("Media")
+ * )
+ */
+class Media extends WizardPluginBase {
+
+  /**
+   * Set the created column.
+   */
+  protected $createdColumn = 'media_field_data-created';
+
+  /**
+   * Set default values for the filters.
+   */
+  protected $filters = [
+    'status' => [
+      'value' => TRUE,
+      'table' => 'media_field_data',
+      'field' => 'status',
+      'plugin_id' => 'boolean',
+      'entity_type' => 'media',
+      'entity_field' => 'status',
+    ],
+  ];
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getAvailableSorts() {
+    return [
+      'media_field_data-name:DESC' => $this->t('Media name'),
+    ];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function defaultDisplayOptions() {
+    $display_options = parent::defaultDisplayOptions();
+
+    // Add permission-based access control.
+    $display_options['access']['type'] = 'perm';
+    $display_options['access']['options']['perm'] = 'view media';
+
+    // Remove the default fields, since we are customizing them here.
+    unset($display_options['fields']);
+
+    // Add the name field, so that the display has content if the user switches
+    // to a row style that uses fields.
+    /* Field: Media: Name */
+    $display_options['fields']['name']['id'] = 'name';
+    $display_options['fields']['name']['table'] = 'media_field_data';
+    $display_options['fields']['name']['field'] = 'name';
+    $display_options['fields']['name']['entity_type'] = 'media';
+    $display_options['fields']['name']['entity_field'] = 'media';
+    $display_options['fields']['name']['label'] = '';
+    $display_options['fields']['name']['alter']['alter_text'] = 0;
+    $display_options['fields']['name']['alter']['make_link'] = 0;
+    $display_options['fields']['name']['alter']['absolute'] = 0;
+    $display_options['fields']['name']['alter']['trim'] = 0;
+    $display_options['fields']['name']['alter']['word_boundary'] = 0;
+    $display_options['fields']['name']['alter']['ellipsis'] = 0;
+    $display_options['fields']['name']['alter']['strip_tags'] = 0;
+    $display_options['fields']['name']['alter']['html'] = 0;
+    $display_options['fields']['name']['hide_empty'] = 0;
+    $display_options['fields']['name']['empty_zero'] = 0;
+    $display_options['fields']['name']['settings']['link_to_entity'] = 1;
+    $display_options['fields']['name']['plugin_id'] = 'field';
+
+    return $display_options;
+  }
+
+}
diff --git a/core/modules/media_entity/src/Plugin/views/wizard/MediaRevision.php b/core/modules/media_entity/src/Plugin/views/wizard/MediaRevision.php
new file mode 100644
index 0000000..72bceb0
--- /dev/null
+++ b/core/modules/media_entity/src/Plugin/views/wizard/MediaRevision.php
@@ -0,0 +1,95 @@
+<?php
+
+namespace Drupal\media_entity\Plugin\views\wizard;
+
+use Drupal\views\Plugin\views\wizard\WizardPluginBase;
+
+/**
+ * Tests creating media revision views with the wizard.
+ *
+ * @ViewsWizard(
+ *   id = "media_revision",
+ *   base_table = "media_field_revision",
+ *   title = @Translation("Media revisions")
+ * )
+ */
+class MediaRevision extends WizardPluginBase {
+
+  /**
+   * Set the created column.
+   */
+  protected $createdColumn = 'changed';
+
+  /**
+   * Set default values for the filters.
+   */
+  protected $filters = [
+    'status' => [
+      'value' => TRUE,
+      'table' => 'media_field_revision',
+      'field' => 'status',
+      'plugin_id' => 'boolean',
+      'entity_type' => 'media',
+      'entity_field' => 'status',
+    ],
+  ];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function defaultDisplayOptions() {
+    $display_options = parent::defaultDisplayOptions();
+
+    // Add permission-based access control.
+    $display_options['access']['type'] = 'perm';
+    $display_options['access']['options']['perm'] = 'view all revisions';
+
+    // Remove the default fields, since we are customizing them here.
+    unset($display_options['fields']);
+
+    /* Field: Media revision: Created date */
+    $display_options['fields']['changed']['id'] = 'changed';
+    $display_options['fields']['changed']['table'] = 'media_field_revision';
+    $display_options['fields']['changed']['field'] = 'changed';
+    $display_options['fields']['changed']['entity_type'] = 'media';
+    $display_options['fields']['changed']['entity_field'] = 'changed';
+    $display_options['fields']['changed']['alter']['alter_text'] = FALSE;
+    $display_options['fields']['changed']['alter']['make_link'] = FALSE;
+    $display_options['fields']['changed']['alter']['absolute'] = FALSE;
+    $display_options['fields']['changed']['alter']['trim'] = FALSE;
+    $display_options['fields']['changed']['alter']['word_boundary'] = FALSE;
+    $display_options['fields']['changed']['alter']['ellipsis'] = FALSE;
+    $display_options['fields']['changed']['alter']['strip_tags'] = FALSE;
+    $display_options['fields']['changed']['alter']['html'] = FALSE;
+    $display_options['fields']['changed']['hide_empty'] = FALSE;
+    $display_options['fields']['changed']['empty_zero'] = FALSE;
+    $display_options['fields']['changed']['plugin_id'] = 'field';
+    $display_options['fields']['changed']['type'] = 'timestamp';
+    $display_options['fields']['changed']['settings']['date_format'] = 'medium';
+    $display_options['fields']['changed']['settings']['custom_date_format'] = '';
+    $display_options['fields']['changed']['settings']['timezone'] = '';
+
+    /* Field: Media revision: Name */
+    $display_options['fields']['name']['id'] = 'name';
+    $display_options['fields']['name']['table'] = 'media_field_revision';
+    $display_options['fields']['name']['field'] = 'name';
+    $display_options['fields']['name']['entity_type'] = 'media';
+    $display_options['fields']['name']['entity_field'] = 'name';
+    $display_options['fields']['name']['label'] = '';
+    $display_options['fields']['name']['alter']['alter_text'] = 0;
+    $display_options['fields']['name']['alter']['make_link'] = 0;
+    $display_options['fields']['name']['alter']['absolute'] = 0;
+    $display_options['fields']['name']['alter']['trim'] = 0;
+    $display_options['fields']['name']['alter']['word_boundary'] = 0;
+    $display_options['fields']['name']['alter']['ellipsis'] = 0;
+    $display_options['fields']['name']['alter']['strip_tags'] = 0;
+    $display_options['fields']['name']['alter']['html'] = 0;
+    $display_options['fields']['name']['hide_empty'] = 0;
+    $display_options['fields']['name']['empty_zero'] = 0;
+    $display_options['fields']['name']['settings']['link_to_entity'] = 0;
+    $display_options['fields']['name']['plugin_id'] = 'field';
+
+    return $display_options;
+  }
+
+}
diff --git a/core/modules/media_entity/templates/media.html.twig b/core/modules/media_entity/templates/media.html.twig
new file mode 100644
index 0000000..9d43771
--- /dev/null
+++ b/core/modules/media_entity/templates/media.html.twig
@@ -0,0 +1,19 @@
+{#
+/**
+ * @file
+ * Default theme implementation to present a media entity.
+ *
+ * Available variables:
+ * - name: Name of the media.
+ * - content: Media content.
+ *
+ * @see template_preprocess_media()
+ *
+ * @ingroup themeable
+ */
+#}
+<article{{ attributes }}>
+  {% if content %}
+    {{ content }}
+  {% endif %}
+</article>
diff --git a/core/modules/media_entity/tests/modules/media_entity_test_bundle/config/install/media_entity.bundle.test.yml b/core/modules/media_entity/tests/modules/media_entity_test_bundle/config/install/media_entity.bundle.test.yml
new file mode 100644
index 0000000..c0a0f70
--- /dev/null
+++ b/core/modules/media_entity/tests/modules/media_entity_test_bundle/config/install/media_entity.bundle.test.yml
@@ -0,0 +1,9 @@
+id: test
+label: 'Test bundle'
+description: 'Test bundle.'
+type: generic
+type_configuration: {  }
+status: true
+langcode: en
+dependencies: {  }
+field_map: {  }
diff --git a/core/modules/media_entity/tests/modules/media_entity_test_bundle/media_entity_test_bundle.info.yml b/core/modules/media_entity/tests/modules/media_entity_test_bundle/media_entity_test_bundle.info.yml
new file mode 100644
index 0000000..9969dad
--- /dev/null
+++ b/core/modules/media_entity/tests/modules/media_entity_test_bundle/media_entity_test_bundle.info.yml
@@ -0,0 +1,6 @@
+name: 'Media entity test bundle'
+type: module
+description: 'Provides test bundle for media entity.'
+core: 8.x
+package: Testing
+version: VERSION
diff --git a/core/modules/media_entity/tests/modules/media_entity_test_type/config/schema/media_entity_test_type.schema.yml b/core/modules/media_entity/tests/modules/media_entity_test_type/config/schema/media_entity_test_type.schema.yml
new file mode 100644
index 0000000..6ff7e14
--- /dev/null
+++ b/core/modules/media_entity/tests/modules/media_entity_test_type/config/schema/media_entity_test_type.schema.yml
@@ -0,0 +1,7 @@
+media_entity.bundle.type.test_type:
+  type: mapping
+  label: 'Test type configuration'
+  mapping:
+    test_config_value:
+      type: string
+      label: 'Test config value'
diff --git a/core/modules/media_entity/tests/modules/media_entity_test_type/media_entity_test_type.info.yml b/core/modules/media_entity/tests/modules/media_entity_test_type/media_entity_test_type.info.yml
new file mode 100644
index 0000000..ed82c4c
--- /dev/null
+++ b/core/modules/media_entity/tests/modules/media_entity_test_type/media_entity_test_type.info.yml
@@ -0,0 +1,6 @@
+name: 'Test media type'
+type: module
+description: 'Provides test media type plugin to test configuration forms.'
+core: 8.x
+package: Testing
+version: VERSION
diff --git a/core/modules/media_entity/tests/modules/media_entity_test_type/src/Plugin/MediaEntity/Type/TestType.php b/core/modules/media_entity/tests/modules/media_entity_test_type/src/Plugin/MediaEntity/Type/TestType.php
new file mode 100644
index 0000000..60d68a0
--- /dev/null
+++ b/core/modules/media_entity/tests/modules/media_entity_test_type/src/Plugin/MediaEntity/Type/TestType.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace Drupal\media_entity_test_type\Plugin\MediaEntity\Type;
+
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\media_entity\Plugin\MediaEntity\Type\Generic;
+
+/**
+ * Provides generic media type.
+ *
+ * @MediaType(
+ *   id = "test_type",
+ *   label = @Translation("Test type"),
+ *   description = @Translation("Test media type.")
+ * )
+ */
+class TestType extends Generic {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function providedFields() {
+    return [
+      'field_1' => $this->t('Field 1'),
+      'field_2' => $this->t('Field 2'),
+    ];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function defaultConfiguration() {
+    return [
+      'test_config_value' => 'This is default value.',
+    ];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
+    $form['test_config_value'] = [
+      '#type' => 'textfield',
+      '#title' => $this->t('Test config value'),
+      '#default_value' => empty($this->configuration['test_config_value']) ? NULL : $this->configuration['test_config_value'],
+    ];
+
+    return $form;
+  }
+
+}
diff --git a/core/modules/media_entity/tests/modules/media_entity_test_views/config/install/views.view.test_media_entity_bulk_form.yml b/core/modules/media_entity/tests/modules/media_entity_test_views/config/install/views.view.test_media_entity_bulk_form.yml
new file mode 100644
index 0000000..5c068b6
--- /dev/null
+++ b/core/modules/media_entity/tests/modules/media_entity_test_views/config/install/views.view.test_media_entity_bulk_form.yml
@@ -0,0 +1,154 @@
+langcode: en
+status: true
+dependencies:
+  module:
+    - media_entity
+    - user
+id: test_media_entity_bulk_form
+label: ''
+module: views
+description: ''
+tag: ''
+base_table: media_field_data
+base_field: mid
+core: 8.x
+display:
+  default:
+    display_plugin: default
+    id: default
+    display_title: Master
+    position: 0
+    display_options:
+      style:
+        type: table
+      row:
+        type: fields
+      fields:
+        media_bulk_form:
+          id: media_bulk_form
+          table: media
+          field: media_bulk_form
+          element_type: ''
+          element_class: ''
+          element_label_type: ''
+          element_label_class: ''
+          element_label_colon: false
+          element_wrapper_type: ''
+          element_wrapper_class: ''
+          element_default_classes: true
+          empty: ''
+          hide_empty: false
+          empty_zero: false
+          hide_alter_empty: true
+          action_title: 'With selection'
+          include_exclude: exclude
+          selected_actions: {  }
+          entity_type: media
+          plugin_id: media_bulk_form
+        name:
+          id: name
+          table: media_field_data
+          field: name
+          entity_type: media
+          entity_field: media
+          hide_empty: false
+          empty_zero: false
+          settings:
+            link_to_entity: false
+          plugin_id: field
+          relationship: none
+          group_type: group
+          admin_label: ''
+          label: 'Media name'
+          exclude: false
+          element_type: ''
+          element_class: ''
+          element_label_type: ''
+          element_label_class: ''
+          element_label_colon: true
+          element_wrapper_type: ''
+          element_wrapper_class: ''
+          element_default_classes: true
+          empty: ''
+          hide_alter_empty: true
+          click_sort_column: value
+          type: string
+          group_column: value
+          group_columns: {  }
+          group_rows: true
+          delta_limit: 0
+          delta_offset: 0
+          delta_reversed: false
+          delta_first_last: false
+          multi_type: separator
+          separator: ', '
+          field_api_classes: false
+        status:
+          id: status
+          table: media_field_data
+          field: status
+          relationship: none
+          group_type: group
+          admin_label: ''
+          label: Status
+          exclude: false
+          element_type: ''
+          element_class: ''
+          element_label_type: ''
+          element_label_class: ''
+          element_label_colon: true
+          element_wrapper_type: ''
+          element_wrapper_class: ''
+          element_default_classes: true
+          empty: ''
+          hide_empty: false
+          empty_zero: false
+          hide_alter_empty: true
+          click_sort_column: value
+          type: boolean
+          settings:
+            format: custom
+            format_custom_true: Published
+            format_custom_false: Unpublished
+          group_column: value
+          group_columns: {  }
+          group_rows: true
+          delta_limit: 0
+          delta_offset: 0
+          delta_reversed: false
+          delta_first_last: false
+          multi_type: separator
+          separator: ', '
+          field_api_classes: false
+          entity_type: media
+          entity_field: status
+          plugin_id: field
+      sorts:
+        mid:
+          id: mid
+          table: media_field_data
+          field: mid
+          relationship: none
+          group_type: group
+          admin_label: ''
+          order: ASC
+          exposed: false
+          expose:
+            label: ''
+          entity_type: media
+          entity_field: mid
+          plugin_id: standard
+      title: 'Entity bulk form test view'
+      header: {  }
+      footer: {  }
+      empty: {  }
+      relationships: {  }
+      arguments: {  }
+      display_extenders: {  }
+  page_1:
+    display_plugin: page
+    id: page_1
+    display_title: Page
+    position: 1
+    display_options:
+      path: test-media-entity-bulk-form
diff --git a/core/modules/media_entity/tests/modules/media_entity_test_views/media_entity_test_views.info.yml b/core/modules/media_entity/tests/modules/media_entity_test_views/media_entity_test_views.info.yml
new file mode 100644
index 0000000..3c93c11
--- /dev/null
+++ b/core/modules/media_entity/tests/modules/media_entity_test_views/media_entity_test_views.info.yml
@@ -0,0 +1,9 @@
+name: 'Media Entity test views'
+type: module
+description: 'Provides default views for views media entity tests.'
+package: Testing
+version: VERSION
+core: 8.x
+dependencies:
+  - media_entity
+  - views
diff --git a/core/modules/media_entity/tests/src/Functional/MediaAccessTest.php b/core/modules/media_entity/tests/src/Functional/MediaAccessTest.php
new file mode 100644
index 0000000..b774fb5
--- /dev/null
+++ b/core/modules/media_entity/tests/src/Functional/MediaAccessTest.php
@@ -0,0 +1,102 @@
+<?php
+
+namespace Drupal\Tests\media_entity\Functional;
+
+use Drupal\media_entity\Entity\Media;
+use Drupal\user\Entity\Role;
+
+/**
+ * Basic access tests for Media Entity.
+ *
+ * @group media_entity
+ */
+class MediaAccessTest extends MediaEntityFunctionalTestBase {
+
+  /**
+   * The test media bundle.
+   *
+   * @var \Drupal\media_entity\MediaBundleInterface
+   */
+  protected $testBundle;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    $this->testBundle = $this->drupalCreateMediaBundle();
+  }
+
+  /**
+   * Test some access control functionality.
+   */
+  public function testMediaAccess() {
+
+    $assert_session = $this->assertSession();
+
+    // Create media.
+    $media = Media::create([
+      'bundle' => $this->testBundle->id(),
+      'name' => 'Unnamed',
+    ]);
+    $media->save();
+    $user_media = Media::create([
+      'bundle' => $this->testBundle->id(),
+      'name' => 'Unnamed',
+      'uid' => $this->nonAdminUser->id(),
+    ]);
+    $user_media->save();
+
+    // We are logged-in as admin, so test 'administer media' permission.
+    $this->drupalGet('media/' . $user_media->id());
+    $assert_session->statusCodeEquals(200);
+    $this->drupalGet('media/' . $user_media->id() . '/edit');
+    $assert_session->statusCodeEquals(200);
+    $this->drupalGet('media/' . $user_media->id() . '/delete');
+    $assert_session->statusCodeEquals(200);
+
+    $this->drupalLogin($this->nonAdminUser);
+    /** @var \Drupal\user\RoleInterface $role */
+    $role = Role::load('authenticated');
+
+    // Test 'view media' permission.
+    $this->drupalGet('media/' . $media->id());
+    $assert_session->statusCodeEquals(403);
+    $this->grantPermissions($role, ['view media']);
+    $this->drupalGet('media/' . $media->id());
+    $assert_session->statusCodeEquals(200);
+
+    // Test 'create media' permission.
+    $this->drupalGet('media/add/' . $this->testBundle->id());
+    $assert_session->statusCodeEquals(403);
+    $this->grantPermissions($role, ['create media']);
+    $this->drupalGet('media/add/' . $this->testBundle->id());
+    $assert_session->statusCodeEquals(200);
+
+    // Test 'update media' and 'delete media' permissions.
+    $this->drupalGet('media/' . $user_media->id() . '/edit');
+    $assert_session->statusCodeEquals(403);
+    $this->drupalGet('media/' . $user_media->id() . '/delete');
+    $assert_session->statusCodeEquals(403);
+    $this->grantPermissions($role, ['update media']);
+    $this->grantPermissions($role, ['delete media']);
+    $this->drupalGet('media/' . $user_media->id() . '/edit');
+    $assert_session->statusCodeEquals(200);
+    $this->drupalGet('media/' . $user_media->id() . '/delete');
+    $assert_session->statusCodeEquals(200);
+
+    // Test 'update any media' and 'delete any media' permissions.
+    $this->drupalGet('media/' . $media->id() . '/edit');
+    $assert_session->statusCodeEquals(403);
+    $this->drupalGet('media/' . $media->id() . '/delete');
+    $assert_session->statusCodeEquals(403);
+    $this->grantPermissions($role, ['update any media']);
+    $this->grantPermissions($role, ['delete any media']);
+    $this->drupalGet('media/' . $media->id() . '/edit');
+    $assert_session->statusCodeEquals(200);
+    $this->drupalGet('media/' . $media->id() . '/delete');
+    $assert_session->statusCodeEquals(200);
+
+  }
+
+}
diff --git a/core/modules/media_entity/tests/src/Functional/MediaBulkFormTest.php b/core/modules/media_entity/tests/src/Functional/MediaBulkFormTest.php
new file mode 100644
index 0000000..5429766
--- /dev/null
+++ b/core/modules/media_entity/tests/src/Functional/MediaBulkFormTest.php
@@ -0,0 +1,118 @@
+<?php
+
+namespace Drupal\Tests\media_entity\Functional;
+
+use Drupal\media_entity\Entity\Media;
+use Drupal\views\Views;
+
+/**
+ * Tests a media bulk form.
+ *
+ * @group media_entity
+ */
+class MediaBulkFormTest extends MediaEntityFunctionalTestBase {
+
+  /**
+   * Modules to be enabled.
+   *
+   * @var array
+   */
+  public static $modules = ['media_entity_test_views'];
+
+  /**
+   * The test media bundle.
+   *
+   * @var \Drupal\media_entity\MediaBundleInterface
+   */
+  protected $testBundle;
+
+  /**
+   * The test media entities.
+   *
+   * @var \Drupal\media_entity\MediaInterface[]
+   */
+  protected $mediaEntities;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    $this->testBundle = $this->drupalCreateMediaBundle();
+
+    // Create some test media entities.
+    $this->mediaEntities = [];
+    for ($i = 1; $i <= 5; $i++) {
+      $media = Media::create([
+        'bundle' => $this->testBundle->id(),
+      ]);
+      $media->save();
+      $this->mediaEntities[] = $media;
+    }
+
+  }
+
+  /**
+   * Tests the media bulk form.
+   */
+  public function testBulkForm() {
+
+    $session = $this->getSession();
+    $page = $session->getPage();
+    $assert_session = $this->assertSession();
+
+    // Check that all created entities are present in the test view.
+    $view = Views::getView('test_media_entity_bulk_form');
+    $view->execute();
+    $this->assertEquals($view->total_rows, 5);
+
+    // Check the operations are accessible to the logged in user.
+    $this->drupalGet('test-media-entity-bulk-form');
+    // Current available actions: Delete, Save, Publish, Unpublish.
+    $available_actions = [
+      'media_delete_action',
+      'media_publish_action',
+      'media_save_action',
+      'media_unpublish_action',
+    ];
+    foreach ($available_actions as $action_name) {
+      $assert_session->optionExists('action', $action_name);
+    }
+
+    // Test unpublishing in bulk.
+    $page->checkField('media_bulk_form[0]');
+    $page->checkField('media_bulk_form[1]');
+    $page->checkField('media_bulk_form[2]');
+    $page->selectFieldOption('action', 'media_unpublish_action');
+    $page->pressButton('Apply to selected items');
+    $assert_session->pageTextContains('Unpublish media was applied to 3 items');
+    for ($i = 1; $i <= 3; $i++) {
+      $this->assertFalse($this->storage->loadUnchanged($i)->isPublished(), 'The unpublish action failed in some of the media entities.');
+    }
+
+    // Test publishing in bulk.
+    $page->checkField('media_bulk_form[0]');
+    $page->checkField('media_bulk_form[1]');
+    $page->selectFieldOption('action', 'media_publish_action');
+    $page->pressButton('Apply to selected items');
+    $assert_session->pageTextContains('Publish media was applied to 2 items');
+    for ($i = 1; $i <= 2; $i++) {
+      $this->assertTrue($this->storage->loadUnchanged($i)->isPublished(), 'The publish action failed in some of the media entities.');
+    }
+
+    // Test deletion in bulk.
+    $page->checkField('media_bulk_form[0]');
+    $page->checkField('media_bulk_form[1]');
+    $page->selectFieldOption('action', 'media_delete_action');
+    $page->pressButton('Apply to selected items');
+    $assert_session->pageTextContains('Are you sure you want to delete these items?');
+    $page->pressButton('Delete');
+    $assert_session->pageTextContains('Deleted 2 media entities.');
+    for ($i = 1; $i <= 2; $i++) {
+      $this->assertNull($this->storage->loadUnchanged($i), 'Could not delete some of the media entities.');
+    }
+
+  }
+
+}
diff --git a/core/modules/media_entity/tests/src/Functional/MediaEntityFunctionalTestBase.php b/core/modules/media_entity/tests/src/Functional/MediaEntityFunctionalTestBase.php
new file mode 100644
index 0000000..5ddac2f
--- /dev/null
+++ b/core/modules/media_entity/tests/src/Functional/MediaEntityFunctionalTestBase.php
@@ -0,0 +1,93 @@
+<?php
+
+namespace Drupal\Tests\media_entity\Functional;
+
+use Drupal\Tests\BrowserTestBase;
+
+/**
+ * Base class for Media Entity functional tests.
+ *
+ * @package Drupal\Tests\media_entity\Functional
+ */
+abstract class MediaEntityFunctionalTestBase extends BrowserTestBase {
+
+  use MediaEntityFunctionalTestTrait;
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = [
+    'system',
+    'node',
+    'field_ui',
+    'views_ui',
+    'media_entity',
+  ];
+
+  /**
+   * Permissions for the admin user that will be logged-in for test.
+   *
+   * @var array
+   */
+  protected static $adminUserPermissions = [
+    // Media entity permissions.
+    'administer media',
+    'administer media fields',
+    'administer media form display',
+    'administer media display',
+    'administer media bundles',
+    'view media',
+    'create media',
+    'update media',
+    'update any media',
+    'delete media',
+    'delete any media',
+    // Other permissions.
+    'administer views',
+    'access content overview',
+    'view all revisions',
+    'administer content types',
+    'administer node fields',
+    'administer node form display',
+    'bypass node access',
+  ];
+
+  /**
+   * An admin test user account.
+   *
+   * @var \Drupal\Core\Session\AccountInterface;
+   */
+  protected $adminUser;
+
+  /**
+   * A non-admin test user account.
+   *
+   * @var \Drupal\Core\Session\AccountInterface;
+   */
+  protected $nonAdminUser;
+
+  /**
+   * The storage service.
+   *
+   * @var \Drupal\Core\Entity\EntityStorageInterface;
+   */
+  protected $storage;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    // Have two users ready to be used in tests.
+    $this->adminUser = $this->drupalCreateUser(static::$adminUserPermissions);
+    $this->nonAdminUser = $this->drupalCreateUser([]);
+    // Start off logged in as admin.
+    $this->drupalLogin($this->adminUser);
+
+    $this->storage = $this->container->get('entity_type.manager')->getStorage('media');
+  }
+
+}
diff --git a/core/modules/media_entity/tests/src/Functional/MediaEntityFunctionalTestTrait.php b/core/modules/media_entity/tests/src/Functional/MediaEntityFunctionalTestTrait.php
new file mode 100644
index 0000000..4e2eedf
--- /dev/null
+++ b/core/modules/media_entity/tests/src/Functional/MediaEntityFunctionalTestTrait.php
@@ -0,0 +1,50 @@
+<?php
+
+namespace Drupal\Tests\media_entity\Functional;
+
+use Drupal\media_entity\Entity\MediaBundle;
+
+/**
+ * Trait with helpers for Media Entity functional tests.
+ *
+ * @package Drupal\Tests\media_entity\Functional
+ */
+trait MediaEntityFunctionalTestTrait {
+
+  /**
+   * Creates a media bundle.
+   *
+   * @param array $values
+   *   The media bundle values.
+   * @param string $type_name
+   *   (optional) The media type provider plugin that is responsible for
+   *   additional logic related to this media).
+   *
+   * @return \Drupal\Core\Entity\EntityInterface
+   *   Returns newly created media bundle.
+   */
+  protected function drupalCreateMediaBundle(array $values = [], $type_name = 'generic') {
+    if (!isset($values['bundle'])) {
+      $id = strtolower($this->randomMachineName());
+    }
+    else {
+      $id = $values['bundle'];
+    }
+    $values += [
+      'id' => $id,
+      'label' => $id,
+      'type' => $type_name,
+      'type_configuration' => [],
+      'field_map' => [],
+      'new_revision' => FALSE,
+    ];
+
+    $bundle = MediaBundle::create($values);
+    $status = $bundle->save();
+
+    $this->assertEquals($status, SAVED_NEW, 'Could not create a media bundle of type ' . $type_name . '.');
+
+    return $bundle;
+  }
+
+}
diff --git a/core/modules/media_entity/tests/src/Functional/MediaUiFunctionalTest.php b/core/modules/media_entity/tests/src/Functional/MediaUiFunctionalTest.php
new file mode 100644
index 0000000..0fc0121
--- /dev/null
+++ b/core/modules/media_entity/tests/src/Functional/MediaUiFunctionalTest.php
@@ -0,0 +1,166 @@
+<?php
+
+namespace Drupal\Tests\media_entity\Functional;
+
+use Drupal\media_entity\Entity\Media;
+
+/**
+ * Ensures that media UI works correctly.
+ *
+ * @group media_entity
+ */
+class MediaUiFunctionalTest extends MediaEntityFunctionalTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = [
+    'block',
+    'media_entity_test_type',
+  ];
+
+  /**
+   * The test media bundle.
+   *
+   * @var \Drupal\media_entity\MediaBundleInterface
+   */
+  protected $testBundle;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    $this->drupalPlaceBlock('local_actions_block');
+    $this->drupalPlaceBlock('local_tasks_block');
+  }
+
+  /**
+   * Tests the media actions (add/edit/delete).
+   */
+  public function testMediaWithOnlyOneBundle() {
+    $session = $this->getSession();
+    $page = $session->getPage();
+    $assert_session = $this->assertSession();
+
+    /** @var \Drupal\media_entity\MediaBundleInterface $bundle */
+    $bundle = $this->drupalCreateMediaBundle(['new_revision' => TRUE]);
+
+    $this->drupalGet('media/add');
+    $assert_session->statusCodeEquals(200);
+    $assert_session->addressEquals('media/add/' . $bundle->id());
+    $assert_session->checkboxChecked('edit-revision');
+
+    // Tests media item add form.
+    $media_name = $this->randomMachineName();
+    $page->fillField('name[0][value]', $media_name);
+    $revision_log_message = $this->randomString();
+    $page->fillField('revision_log', $revision_log_message);
+    $page->pressButton('Save and publish');
+    $media_id = $this->container->get('entity.query')->get('media')->execute();
+    $media_id = reset($media_id);
+    /** @var \Drupal\media_entity\MediaInterface $media */
+    $media = $this->container->get('entity_type.manager')
+      ->getStorage('media')
+      ->loadUnchanged($media_id);
+    $this->assertEquals($media->getRevisionLogMessage(), $revision_log_message);
+    $assert_session->titleEquals($media->label() . ' | Drupal');
+
+    // Tests media edit form.
+    $bundle->setNewRevision(FALSE);
+    $bundle->save();
+    $media_name2 = $this->randomMachineName();
+    $this->drupalGet('media/' . $media_id . '/edit');
+    $assert_session->checkboxNotChecked('edit-revision');
+    $media_name = $this->randomMachineName();
+    $page->fillField('name[0][value]', $media_name2);
+    $page->pressButton('Save and keep published');
+    $assert_session->titleEquals($media_name2 . ' | Drupal');
+
+    // Test that there is no empty vertical tabs element, if the container is
+    // empty (see #2750697).
+    // Make the "Publisher ID" and "Created" fields hidden.
+    $this->drupalGet('/admin/structure/media/manage/' . $bundle->id . '/form-display');
+    $page->selectFieldOption('fields[created][parent]', 'hidden');
+    $page->selectFieldOption('fields[uid][parent]', 'hidden');
+    $page->pressButton('Save');
+    // Assure we are testing with a user without permission to manage revisions.
+    $this->drupalLogin($this->nonAdminUser);
+    // Check the container is not present.
+    $this->drupalGet('media/' . $media_id . '/edit');
+    // An empty tab container would look like this.
+    $raw_html = '<div data-drupal-selector="edit-advanced" data-vertical-tabs-panes><input class="vertical-tabs__active-tab" data-drupal-selector="edit-advanced-active-tab" type="hidden" name="advanced__active_tab" value="" />' . "\n" . '</div>';
+    $assert_session->responseNotContains($raw_html);
+    // Continue testing as admin.
+    $this->drupalLogin($this->adminUser);
+
+    // Enable revisions by default.
+    $bundle->setNewRevision(TRUE);
+    $bundle->save();
+    $this->drupalGet('media/' . $media_id . '/edit');
+    $assert_session->checkboxChecked('edit-revision');
+    $page->fillField('name[0][value]', $media_name);
+    $page->fillField('revision_log', $revision_log_message);
+    $page->pressButton('Save and keep published');
+    $assert_session->titleEquals($media_name . ' | Drupal');
+    /** @var \Drupal\media_entity\MediaInterface $media */
+    $media = $this->container->get('entity_type.manager')
+      ->getStorage('media')
+      ->loadUnchanged($media_id);
+    $this->assertEquals($media->getRevisionLogMessage(), $revision_log_message);
+
+    // Tests media delete form.
+    $this->drupalGet('media/' . $media_id . '/edit');
+    $page->clickLink('Delete');
+    $assert_session->pageTextContains('This action cannot be undone');
+    $page->pressButton('Delete');
+    $media_id = \Drupal::entityQuery('media')->execute();
+    $this->assertFalse($media_id);
+  }
+
+  /**
+   * Tests the "media/add" and "media/mid" pages.
+   *
+   * Tests if the "media/add" page gives you a selecting option if there are
+   * multiple media bundles available.
+   */
+  public function testMediaWithMultipleBundles() {
+    $assert_session = $this->assertSession();
+
+    // Tests and creates the first media bundle.
+    $first_media_bundle = $this->drupalCreateMediaBundle(['description' => $this->randomMachineName(32)]);
+
+    // Test and create a second media bundle.
+    $second_media_bundle = $this->drupalCreateMediaBundle(['description' => $this->randomMachineName(32)]);
+
+    // Test if media/add displays two media bundle options.
+    $this->drupalGet('media/add');
+
+    // Checks for the first media bundle.
+    $assert_session->pageTextContains($first_media_bundle->label());
+    $assert_session->pageTextContains($first_media_bundle->description);
+    // Checks for the second media bundle.
+    $assert_session->pageTextContains($second_media_bundle->label());
+    $assert_session->pageTextContains($second_media_bundle->description);
+
+    // Continue testing media bundle filter.
+    $first_media_item = Media::create(['bundle' => $first_media_bundle->id()]);
+    $first_media_item->save();
+    $second_media_item = Media::create(['bundle' => $second_media_bundle->id()]);
+    $second_media_item->save();
+
+    // Go to first media item.
+    $this->drupalGet('media/' . $first_media_item->id());
+    $assert_session->statusCodeEquals(200);
+    $assert_session->pageTextContains($first_media_item->label());
+
+    // Go to second media item.
+    $this->drupalGet('media/' . $second_media_item->id());
+    $assert_session->statusCodeEquals(200);
+    $assert_session->pageTextContains($second_media_item->label());
+
+  }
+
+}
diff --git a/core/modules/media_entity/tests/src/FunctionalJavascript/MediaEntityJavascriptTestBase.php b/core/modules/media_entity/tests/src/FunctionalJavascript/MediaEntityJavascriptTestBase.php
new file mode 100644
index 0000000..4f214f3
--- /dev/null
+++ b/core/modules/media_entity/tests/src/FunctionalJavascript/MediaEntityJavascriptTestBase.php
@@ -0,0 +1,109 @@
+<?php
+
+namespace Drupal\Tests\media_entity\FunctionalJavascript;
+
+use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\Tests\media_entity\Functional\MediaEntityFunctionalTestTrait;
+
+/**
+ * Base class for Media Entity Javascript functional tests.
+ *
+ * @package Drupal\Tests\media_entity\FunctionalJavascript
+ */
+abstract class MediaEntityJavascriptTestBase extends JavascriptTestBase {
+
+  use MediaEntityFunctionalTestTrait;
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = [
+    'system',
+    'node',
+    'field_ui',
+    'views_ui',
+    'media_entity',
+  ];
+
+  /**
+   * Permissions for the admin user that will be logged-in for test.
+   *
+   * @var array
+   */
+  protected static $adminUserPermissions = [
+    // Media entity permissions.
+    'administer media',
+    'administer media fields',
+    'administer media form display',
+    'administer media display',
+    'administer media bundles',
+    'view media',
+    'create media',
+    'update media',
+    'update any media',
+    'delete media',
+    'delete any media',
+    // Other permissions.
+    'administer views',
+    'access content overview',
+    'view all revisions',
+    'administer content types',
+    'administer node fields',
+    'administer node form display',
+    'bypass node access',
+  ];
+
+  /**
+   * An admin test user account.
+   *
+   * @var \Drupal\Core\Session\AccountInterface;
+   */
+  protected $adminUser;
+
+  /**
+   * A non-admin test user account.
+   *
+   * @var \Drupal\Core\Session\AccountInterface;
+   */
+  protected $nonAdminUser;
+
+  /**
+   * The storage service.
+   *
+   * @var \Drupal\Core\Entity\EntityStorageInterface;
+   */
+  protected $storage;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    // Have two users ready to be used in tests.
+    $this->adminUser = $this->drupalCreateUser(static::$adminUserPermissions);
+    $this->nonAdminUser = $this->drupalCreateUser([]);
+    // Start off logged in as admin.
+    $this->drupalLogin($this->adminUser);
+
+    $this->storage = $this->container->get('entity_type.manager')->getStorage('media');
+  }
+
+  /**
+   * Waits and asserts that a given element is visible.
+   *
+   * @param string $selector
+   *   The CSS selector.
+   * @param int $timeout
+   *   (Optional) Timeout in milliseconds, defaults to 1000.
+   * @param string $message
+   *   (Optional) Message to pass to assertJsCondition().
+   */
+  protected function waitUntilVisible($selector, $timeout = 1000, $message = '') {
+    $condition = "jQuery('" . $selector . ":visible').length > 0";
+    $this->assertJsCondition($condition, $timeout, $message);
+  }
+
+}
diff --git a/core/modules/media_entity/tests/src/FunctionalJavascript/MediaUiJavascriptTest.php b/core/modules/media_entity/tests/src/FunctionalJavascript/MediaUiJavascriptTest.php
new file mode 100644
index 0000000..c8219fe
--- /dev/null
+++ b/core/modules/media_entity/tests/src/FunctionalJavascript/MediaUiJavascriptTest.php
@@ -0,0 +1,170 @@
+<?php
+
+namespace Drupal\Tests\media_entity\FunctionalJavascript;
+
+use Drupal\media_entity\Entity\Media;
+
+/**
+ * Ensures that media UI works correctly.
+ *
+ * @group media_entity
+ */
+class MediaUiJavascriptTest extends MediaEntityJavascriptTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = [
+    'block',
+    'media_entity_test_type',
+  ];
+
+  /**
+   * The test media bundle.
+   *
+   * @var \Drupal\media_entity\MediaBundleInterface
+   */
+  protected $testBundle;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    $this->drupalPlaceBlock('local_actions_block');
+    $this->drupalPlaceBlock('local_tasks_block');
+  }
+
+  /**
+   * Tests a media bundle administration.
+   */
+  public function testMediaBundles() {
+    $session = $this->getSession();
+    $page = $session->getPage();
+    $assert_session = $this->assertSession();
+
+    // Test the creation of a media bundle using the UI.
+    $name = $this->randomMachineName();
+    $description = $this->randomMachineName();
+    $this->drupalGet('admin/structure/media/add');
+    $page->fillField('label', $name);
+    $session->wait(2000);
+    $page->selectFieldOption('type', 'generic');
+    $page->fillField('description', $description);
+    $page->pressButton('Save media bundle');
+    $assert_session->statusCodeEquals(200);
+    $assert_session->pageTextContains('The media bundle ' . $name . ' has been added.');
+    $this->drupalGet('admin/structure/media');
+    $assert_session->statusCodeEquals(200);
+    $assert_session->pageTextContains($name);
+    $assert_session->pageTextContains($description);
+
+    /** @var \Drupal\media_entity\MediaBundleInterface $bundle_storage */
+    $bundle_storage = $this->container->get('entity_type.manager')->getStorage('media_bundle');
+    $this->testBundle = $bundle_storage->load(strtolower($name));
+
+    // Check if all action links exist.
+    $assert_session->linkByHrefExists('admin/structure/media/add');
+    $assert_session->linkByHrefExists('admin/structure/media/manage/' . $this->testBundle->id());
+    $assert_session->linkByHrefExists('admin/structure/media/manage/' . $this->testBundle->id() . '/fields');
+    $assert_session->linkByHrefExists('admin/structure/media/manage/' . $this->testBundle->id() . '/form-display');
+    $assert_session->linkByHrefExists('admin/structure/media/manage/' . $this->testBundle->id() . '/display');
+
+    // Assert that fields have expected values before editing.
+    $page->clickLink('Edit');
+    $assert_session->fieldValueEquals('label', $name);
+    $assert_session->fieldValueEquals('description', $description);
+    $assert_session->fieldValueEquals('type', 'generic');
+    $assert_session->fieldValueEquals('label', $name);
+    $assert_session->checkboxNotChecked('edit-options-new-revision');
+    $assert_session->checkboxChecked('edit-options-status');
+    $assert_session->checkboxNotChecked('edit-options-queue-thumbnail-downloads');
+    $assert_session->pageTextContains('Create new revision');
+    $assert_session->pageTextContains('Automatically create a new revision of media entities. Users with the Administer media permission will be able to override this option.');
+    $assert_session->pageTextContains('Download thumbnails via a queue.');
+    $assert_session->pageTextContains('Entities will be automatically published when they are created.');
+    $assert_session->pageTextContains("This type provider doesn't need configuration.");
+    $assert_session->pageTextContains('No metadata fields available.');
+    $assert_session->pageTextContains('Media type plugins can provide metadata fields such as title, caption, size information, credits, ... Media entity can automatically save this metadata information to entity fields, which can be configured below. Information will only be mapped if the entity field is empty.');
+
+    // Try to change media type and check if new configuration sub-form appears.
+    $page->selectFieldOption('type', 'test_type');
+    $assert_session->assertWaitOnAjaxRequest();
+    $assert_session->fieldExists('Test config value');
+    $assert_session->fieldValueEquals('Test config value', 'This is default value.');
+    $assert_session->fieldExists('Field 1');
+    $assert_session->fieldExists('Field 2');
+
+    // Test if the edit machine name is not editable.
+    $assert_session->fieldDisabled('Machine-readable name');
+
+    // Edit and save media bundle form fields with new values.
+    $new_name = $this->randomMachineName();
+    $new_description = $this->randomMachineName();
+    $page->fillField('label', $new_name);
+    $page->fillField('description', $new_description);
+    $page->selectFieldOption('type', 'test_type');
+    $page->fillField('Test config value', 'This is new config value.');
+    $page->selectFieldOption('field_mapping[field_1]', 'name');
+    $page->checkField('options[new_revision]');
+    $page->uncheckField('options[status]');
+    $page->checkField('options[queue_thumbnail_downloads]');
+    $page->pressButton('Save media bundle');
+    $assert_session->statusCodeEquals(200);
+
+    // Test if edit worked and if new field values have been saved as expected.
+    $this->drupalGet('admin/structure/media/manage/' . $this->testBundle->id());
+    $assert_session->fieldValueEquals('label', $new_name);
+    $assert_session->fieldValueEquals('description', $new_description);
+    $assert_session->fieldValueEquals('type', 'test_type');
+    $assert_session->checkboxChecked('options[new_revision]');
+    $assert_session->checkboxNotChecked('options[status]');
+    $assert_session->checkboxChecked('options[queue_thumbnail_downloads]');
+    $assert_session->fieldValueEquals('Test config value', 'This is new config value.');
+    $assert_session->fieldValueEquals('Field 1', 'name');
+    $assert_session->fieldValueEquals('Field 2', '_none');
+
+    /** @var \Drupal\media_entity\MediaBundleInterface $loaded_bundle */
+    $loaded_bundle = $this->container->get('entity_type.manager')
+      ->getStorage('media_bundle')
+      ->load($this->testBundle->id());
+    $this->assertEquals($loaded_bundle->id(), $this->testBundle->id());
+    $this->assertEquals($loaded_bundle->label(), $new_name);
+    $this->assertEquals($loaded_bundle->getDescription(), $new_description);
+    $this->assertEquals($loaded_bundle->getType()->getPluginId(), 'test_type');
+    $this->assertEquals($loaded_bundle->getType()->getConfiguration()['test_config_value'], 'This is new config value.');
+    $this->assertTrue($loaded_bundle->shouldCreateNewRevision());
+    $this->assertTrue($loaded_bundle->getQueueThumbnailDownloads());
+    $this->assertFalse($loaded_bundle->getStatus());
+    $this->assertEquals($loaded_bundle->field_map, ['field_1' => 'name']);
+
+    // Test that a media being created with default status to "FALSE" will be
+    // created unpublished.
+    /** @var \Drupal\media_entity\MediaInterface $unpublished_media */
+    $unpublished_media = Media::create(['name' => 'unpublished test media', 'bundle' => $loaded_bundle->id()]);
+    $this->assertFalse($unpublished_media->isPublished());
+    $unpublished_media->delete();
+
+    // Tests media bundle delete form.
+    $page->clickLink('Delete');
+    $assert_session->addressEquals('admin/structure/media/manage/' . $this->testBundle->id() . '/delete');
+    $page->pressButton('Delete');
+    $assert_session->addressEquals('admin/structure/media');
+    $assert_session->pageTextContains('The media bundle ' . $new_name . ' has been deleted.');
+
+    // Test bundle delete prevention when there is existing media.
+    $bundle2 = $this->drupalCreateMediaBundle();
+    $label2 = $bundle2->label();
+    $media = Media::create(['name' => 'lorem ipsum', 'bundle' => $bundle2->id()]);
+    $media->save();
+    $this->drupalGet('admin/structure/media/manage/' . $bundle2->id());
+    $page->clickLink('Delete');
+    $assert_session->addressEquals('admin/structure/media/manage/' . $bundle2->id() . '/delete');
+    $assert_session->fieldNotExists('edit-submit');
+    $assert_session->pageTextContains("$label2 is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the $label2 content.");
+
+  }
+
+}
diff --git a/core/modules/media_entity/tests/src/FunctionalJavascript/MediaViewsWizardTest.php b/core/modules/media_entity/tests/src/FunctionalJavascript/MediaViewsWizardTest.php
new file mode 100644
index 0000000..61f64a9
--- /dev/null
+++ b/core/modules/media_entity/tests/src/FunctionalJavascript/MediaViewsWizardTest.php
@@ -0,0 +1,89 @@
+<?php
+
+namespace Drupal\Tests\media_entity\FunctionalJavascript;
+
+use Drupal\views\Views;
+
+/**
+ * Tests the media entity type integration into the wizard.
+ *
+ * @group media_entity
+ *
+ * @see \Drupal\media_entity\Plugin\views\wizard\Media
+ * @see \Drupal\media_entity\Plugin\views\wizard\MediaRevision
+ */
+class MediaViewsWizardTest extends MediaEntityJavascriptTestBase {
+
+  /**
+   * Tests adding a view of media.
+   */
+  public function testMediaWizard() {
+    $session = $this->getSession();
+    $page = $session->getPage();
+    $assert_session = $this->assertSession();
+
+    $view_id = strtolower($this->randomMachineName(16));
+    $this->drupalGet('admin/structure/views/add');
+    $page->fillField('label', $view_id);
+    $session->wait(2000);
+    $page->selectFieldOption('show[wizard_key]', 'media');
+    $assert_session->assertWaitOnAjaxRequest();
+    $page->checkField('page[create]');
+    $page->fillField('page[path]', $this->randomMachineName(16));
+    $page->pressButton('Save and edit');
+    $assert_session->assertWaitOnAjaxRequest();
+    $this->assertEquals($session->getCurrentUrl(), $this->baseUrl . '/admin/structure/views/view/' . $view_id);
+
+    $view = Views::getView($view_id);
+    $view->initHandlers();
+    $row = $view->display_handler->getOption('row');
+    $this->assertEquals($row['type'], 'fields');
+    // Check for the default filters.
+    $this->assertEquals($view->filter['status']->table, 'media_field_data');
+    $this->assertEquals($view->filter['status']->field, 'status');
+    $this->assertTrue($view->filter['status']->value);
+    // Check for the default fields.
+    $this->assertEquals($view->field['name']->table, 'media_field_data');
+    $this->assertEquals($view->field['name']->field, 'name');
+
+  }
+
+  /**
+   * Tests adding a view of media revisions.
+   */
+  public function testMediaRevisionWizard() {
+    $session = $this->getSession();
+    $page = $session->getPage();
+    $assert_session = $this->assertSession();
+
+    $view_id = strtolower($this->randomMachineName(16));
+    $this->drupalGet('admin/structure/views/add');
+    $page->fillField('label', $view_id);
+    $session->wait(2000);
+    $page->selectFieldOption('show[wizard_key]', 'media_revision');
+    $assert_session->assertWaitOnAjaxRequest();
+    $page->checkField('page[create]');
+    $page->fillField('page[path]', $this->randomMachineName(16));
+    $page->pressButton('Save and edit');
+    $assert_session->assertWaitOnAjaxRequest();
+    $this->assertEquals($session->getCurrentUrl(), $this->baseUrl . '/admin/structure/views/view/' . $view_id);
+
+    $view = Views::getView($view_id);
+    $view->initHandlers();
+    $row = $view->display_handler->getOption('row');
+    $this->assertEquals($row['type'], 'fields');
+
+    // Check for the default filters.
+    $this->assertEquals($view->filter['status']->table, 'media_field_revision');
+    $this->assertEquals($view->filter['status']->field, 'status');
+    $this->assertTrue($view->filter['status']->value);
+
+    // Check for the default fields.
+    $this->assertEquals($view->field['name']->table, 'media_field_revision');
+    $this->assertEquals($view->field['name']->field, 'name');
+    $this->assertEquals($view->field['changed']->table, 'media_field_revision');
+    $this->assertEquals($view->field['changed']->field, 'changed');
+
+  }
+
+}
diff --git a/core/modules/media_entity/tests/src/Kernel/BasicCreationTest.php b/core/modules/media_entity/tests/src/Kernel/BasicCreationTest.php
new file mode 100644
index 0000000..d5aef44
--- /dev/null
+++ b/core/modules/media_entity/tests/src/Kernel/BasicCreationTest.php
@@ -0,0 +1,114 @@
+<?php
+
+namespace Drupal\Tests\media_entity\Kernel;
+
+use Drupal\KernelTests\KernelTestBase;
+use Drupal\media_entity\Entity\Media;
+use Drupal\media_entity\Entity\MediaBundle;
+
+/**
+ * Tests creation of Media Bundles and Media Entities.
+ *
+ * @group media_entity
+ */
+class BasicCreationTest extends KernelTestBase {
+
+  /**
+   * Modules to install.
+   *
+   * @var array
+   */
+  public static $modules = [
+    'media_entity',
+    'image',
+    'user',
+    'field',
+    'system',
+    'file',
+  ];
+
+
+  /**
+   * The test media bundle.
+   *
+   * @var \Drupal\media_entity\MediaBundleInterface
+   */
+  protected $testBundle;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    $this->installEntitySchema('user');
+    $this->installEntitySchema('file');
+    $this->installSchema('file', 'file_usage');
+    $this->installEntitySchema('media');
+    $this->installConfig(['field', 'system', 'image', 'file']);
+
+    // Create a test bundle.
+    $id = strtolower($this->randomMachineName());
+    $this->testBundle = MediaBundle::create([
+      'id' => $id,
+      'label' => $id,
+      'type' => 'generic',
+      'type_configuration' => [],
+      'field_map' => [],
+      'new_revision' => FALSE,
+    ]);
+    $this->testBundle->save();
+
+  }
+
+  /**
+   * Tests creating a media bundle programmatically.
+   */
+  public function testMediaBundleCreation() {
+    /** @var \Drupal\media_entity\MediaBundleInterface $bundle_storage */
+    $bundle_storage = $this->container->get('entity_type.manager')->getStorage('media_bundle');
+
+    $bundle_exists = (bool) $bundle_storage->load($this->testBundle->id());
+    $this->assertTrue($bundle_exists, 'The new media bundle has not been correctly created in the database.');
+
+    // Test default bundle created from default configuration.
+    $this->container->get('module_installer')->install(['media_entity_test_bundle']);
+    $test_bundle = $bundle_storage->load('test');
+    $this->assertTrue((bool) $test_bundle, 'The media bundle from default configuration has not been created in the database.');
+    $this->assertEquals($test_bundle->get('label'), 'Test bundle', 'Could not assure the correct bundle label.');
+    $this->assertEquals($test_bundle->get('description'), 'Test bundle.', 'Could not assure the correct bundle description.');
+    $this->assertEquals($test_bundle->get('type'), 'generic', 'Could not assure the correct bundle plugin type.');
+    $this->assertEquals($test_bundle->get('type_configuration'), [], 'Could not assure the correct plugin configuration.');
+    $this->assertEquals($test_bundle->get('field_map'), [], 'Could not assure the correct field map.');
+  }
+
+  /**
+   * Tests creating a media entity programmatically.
+   */
+  public function testMediaEntityCreation() {
+    $media = Media::create([
+      'bundle' => $this->testBundle->id(),
+      'name' => 'Unnamed',
+    ]);
+    $media->save();
+
+    $media_not_exist = (bool) Media::load(rand(1000, 9999));
+    $this->assertFalse($media_not_exist, 'Failed asserting a non-existent media.');
+
+    $media_exists = (bool) Media::load($media->id());
+    $this->assertTrue($media_exists, 'The new media entity has not been created in the database.');
+    $this->assertEquals($media->bundle(), $this->testBundle->id(), 'The media was not created with the correct bundle.');
+    $this->assertEquals($media->label(), 'Unnamed', 'The media was not created with the correct name.');
+
+    // Test the creation of a media without user-defined label and check if a
+    // default name is provided.
+    $media = Media::create([
+      'bundle' => $this->testBundle->id(),
+    ]);
+    $media->save();
+    $expected_name = 'media' . ':' . $this->testBundle->id() . ':' . $media->uuid();
+    $this->assertEquals($media->bundle(), $this->testBundle->id(), 'The media was not created with correct bundle.');
+    $this->assertEquals($media->label(), $expected_name, 'The media was not created with a default name.');
+  }
+
+}
diff --git a/core/modules/media_entity/tests/src/Kernel/TokensTest.php b/core/modules/media_entity/tests/src/Kernel/TokensTest.php
new file mode 100644
index 0000000..7f4800d
--- /dev/null
+++ b/core/modules/media_entity/tests/src/Kernel/TokensTest.php
@@ -0,0 +1,76 @@
+<?php
+
+namespace Drupal\Tests\media_entity\Kernel;
+
+use Drupal\Core\Language\Language;
+use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
+use Drupal\media_entity\Entity\Media;
+use Drupal\media_entity\Entity\MediaBundle;
+
+/**
+ * Tests token handling.
+ *
+ * @group media_entity
+ */
+class TokensTest extends EntityKernelTestBase {
+
+  /**
+   * Modules to install.
+   *
+   * @var array
+   */
+  public static $modules = [
+    'media_entity',
+    'path',
+    'file',
+    'image',
+    'datetime',
+    'language',
+  ];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    $this->installEntitySchema('file');
+    $this->installSchema('file', 'file_usage');
+    $this->installEntitySchema('media');
+    $this->installConfig(['language', 'datetime', 'field', 'system']);
+  }
+
+  /**
+   * Tests some of the tokens provided by media_entity.
+   */
+  public function testMediaEntityTokens() {
+    // Create a generic media bundle.
+    $bundle_name = $this->randomMachineName();
+
+    MediaBundle::create([
+      'id' => $bundle_name,
+      'label' => $bundle_name,
+      'type' => 'generic',
+      'type_configuration' => [],
+      'field_map' => [],
+      'status' => 1,
+      'new_revision' => FALSE,
+    ])->save();
+
+    // Create a media entity.
+    $media = Media::create([
+      'name' => $this->randomMachineName(),
+      'bundle' => $bundle_name,
+      'uid' => '1',
+      'langcode' => Language::LANGCODE_DEFAULT,
+      'status' => Media::PUBLISHED,
+    ]);
+    $media->save();
+
+    $token_service = $this->container->get('token');
+
+    $replaced_value = $token_service->replace('[media:name]', ['media' => $media]);
+    $this->assertEquals($media->label(), $replaced_value, 'Token replacement for the media label was sucessful.');
+
+  }
+
+}
diff --git a/core/themes/classy/templates/content/media.html.twig b/core/themes/classy/templates/content/media.html.twig
new file mode 100644
index 0000000..2bdd59e
--- /dev/null
+++ b/core/themes/classy/templates/content/media.html.twig
@@ -0,0 +1,19 @@
+{#
+/**
+ * @file
+ * Theme override to display a media.
+ *
+ * Available variables:
+ * - name: Name of the media.
+ * - content: Media content.
+ *
+ * @see template_preprocess_media()
+ *
+ * @ingroup themeable
+ */
+#}
+<article{{ attributes }}>
+  {% if content %}
+    {{ content }}
+  {% endif %}
+</article>
diff --git a/core/themes/stable/templates/content/media.html.twig b/core/themes/stable/templates/content/media.html.twig
new file mode 100644
index 0000000..2bdd59e
--- /dev/null
+++ b/core/themes/stable/templates/content/media.html.twig
@@ -0,0 +1,19 @@
+{#
+/**
+ * @file
+ * Theme override to display a media.
+ *
+ * Available variables:
+ * - name: Name of the media.
+ * - content: Media content.
+ *
+ * @see template_preprocess_media()
+ *
+ * @ingroup themeable
+ */
+#}
+<article{{ attributes }}>
+  {% if content %}
+    {{ content }}
+  {% endif %}
+</article>
