Adding media content to a website instantly turns it into an engaging and attractive one. Media like images, videos, audio, slideshows, etc. work wonders in creating better and compelling digital experiences. The Media module for Drupal 8 lets you manage your media elements easily and systematically. The release of Drupal 8.4 saw the inclusion of many media features like the Media module and Media Library in core.
What is Media module?
The Drupal 8 Media module is often called as a ‘File browser to the internet’.
Media module for Drupal 8 lets you manage media files and assets regardless of where they are hosted. With this module you can add/embed different kinds of media to your website content, save them in the Media Library, embed videos with a URL and more.
Drupal 8 Media Entities
The concept of Media entities are similar to that of Nodes. Media types are to media entities as Content types are to nodes. However, with Media entities, every media type is different. For example, an Image media type will come with a different set of features that can be modified (like dimensions) when compared to a video embed with a URL media type. When you enable the Media module, these Media types are created automatically -
- File
- Image
- Audio File
- Video File
- Remote Video
You can also add fields to media types and create your own media types based on your selected media source.
Installation of Media module:
The Media module ships with Drupal 8 core but you will need to enable it first to be able to use it. Here are the steps to enabling and using the Drupal 8 Media module-
Step1:
First we have to go to Extend tab and enable the Media and media library module as shown in the below image.
Step2:
Once we enable the module now we can see that the Media types are part of the site’s structure, which has 5 types - Audio, Image , Remote video, File and video. Here we can create our own type as well.
Step3:
Now we can use this as an entity reference for any field.
For example, here we will create a field for Images as Media type as shown in the below.
Next, we have to select a Reference type of media as shown in the below image.
Step 4:
The field has been created successfully. It is time to add some media of the available types. You can add it in two ways:
- From the admin dashboard “Content -> Add content -> Article” for Image field
- Directly from the “Media” tab in “Content” where you will see the entire Media Library with all media that you have added.
The new Media Library interface can display your media in the Gridview and in the Table view
It is easy to filter and sort the media by various criteria, as well as select particular items to do actions with them (delete, publish, save, unpublish).