Read Managing Media Assets using Core Media in Drupal 8 to learn how to add media management functionality into a Drupal 8.5 site using the core Media module.
I attended a core conversation titled “LET’S FIX FILE AND MEDIA HANDLING ONCE AND FOR ALL” at DrupalCon Prague in 2013.
This got my attention, not because the title was in all caps, but because Drupal needed to fix media management, as the title says: “ONCE AND FOR ALL”.
Let’s face it, Drupal doesn’t handle media very well when compared to other systems. I’ve worked with clients who are used to a certain level of functionality when it comes to managing images or videos on websites.
In Drupal 7 you had a few options.
You could use the Media module. But embedding images through the editor could be buggy depending on which module you’d use to implement the editor, i.e., Wysiwyg or CKEditor.
Then you have Scald, which is a pretty good module. Another module which has been around for a long time is IMCE.
However, adding media management into a Drupal site isn’t as straightforward as you think. That’s why I attended the core conversation in Prague. I too thought Drupal needed a great and robust media system.
Fast forward a couple of years since DrupalCon Prague and things have changed.
Thanks to the work from the Drupal Media team, managing media in Drupal 8 has got a lot better.
Now they are working on getting this functionality in Drupal core, which I think is absolutely amazing.
In this tutorial, I’ll show you how to set up media management in Drupal 8.
3 Parts to Handling Media in Drupal
Everyone has their own definition of media management. In this tutorial, I’m going to focus on three parts:
- Storing assets
- Embedding assets
- Browsing assets
I want to give users the ability to create media assets. Then have a button in the editor which they can use to browse assets and then embed them.
We’ll utilize three modules to handle this: Media Entity, Entity Embed and Entity Browser.
What’s Happened to the Media Module?
In Drupal 7, the Media module was jam-pack with a lot of functionality. In Drupal 8, a lot of its functionality has been broken out into seperate modules. There is a Drupal 8 version of Media and it’ll be used to create an out-of-the-box solution. The module doesn’t do much other than ship a bunch of configuration.
Part 1: How to Create Media Entities
To store media assets you’ll need the Media Entity module. The module itself won’t handle any media, it’s just a base entity.
So you’ll need to download other modules which are media providers. For example, if you want to handle images then download and install “Media entity image“. If you want to handle audio files you’ll need the “Media entity audio” module.
For a full list of media handlers go to the Media Entity project page.
I’m only going to focus on two types of assets in the tutorial: images and embedded videos (YouTube or Vimeo).
Let’s start by downloading the following modules:
Then install, “Media image entity” and “Video embed media” (sub-module of “Video embed field”)
Using Drush:
$ drush dl media_entity entity media_entity_image video_embed_field $ drush en media_entity_image video_embed_media
Create Image Media Bundle
To handle images we’ll need to create a media type for images.
1. Go to Structure and click on “Media bundles”.
From this page you manage all the different media bundles. This is similar to the “Content types” page.
2. Click on “Add media bundle”.
3. Enter Image into Label, “Used for images.” into Description and select Image from the “Type provider” drop-down.
Ignore the other fields for now and scroll to the bottom and click on “Save media bundle”.
You can ignore the “Field with source information” drop-down. We’ll need to create a field and map it after.
4. Now click on “Manage fields” from the Operations drop-down.
We need to create an Image field that’ll be used to store the actual image field.
5. Click on “Add field”, select Image from “Add a new field” and enter Image into the Label field.
6. Leave the “Field settings” page as is and click on “Save field settings” at the bottom.
7. Leave the Edit page as is and click on “Save settings” at the bottom.
8. Click on the Edit tab from the “Manage fields” page to edit the media bundle.
9. Make sure the “Field with source information” drop-down has selected the image field which we created and click on “Save media bundle”.
Type Provider Configuration
The “Media entity” is like any other entity type: it’s fieldable. You can add custom fields, you can configure the form display and general display like you do with content types.
The only difference is, we need to tell the media bundle which field will store the actual file. If you’re creating a document media bundle, then you’d create a File field and select that in “Field with source information”.
Field Mapping
The “Field mapping” section lets you store metadata from the image into custom fields. If you want to store the width, then you’ll need to create a text field and select it from the Width drop-down.
Take note, the possible metadata properties are determined by the type of provider. You’d get different options if you were configuring a document media bundle.
Create Embed Video Media Bundle
Now it’s time to create another media bundle and this one will be used for embedding videos, i.e., YouTube or Vimeo videos.
1. Go back to “Media bundles” and click on “Add media bundles”.
2. Enter “Video embed” into Label, “Used for embedding videos.” into Description and select “Video embed field” from the “Type provider” drop-down.
3. Scroll to the bottom and click on “Save media bundle”.
We won’t have to create a “Video embed” field and map it across like we did for the Image bundle because “Video embed media” module did it for us.
Take note of this message:
So we’ve created our media bundles now let’s look at how to create a media asset.
How to Create a Media Assets
At this point, you can only create assets from the Media page.
1. Go to Content and click on Media.
From this page you can add a media asset and view existing ones.
2. To create an asset just click on “Add media”.
Go ahead and create an image and embeddable video.
Access to Media Entities
By default Media Entity won’t configure permissions. If you want to allow anonymous users access to the assets then you’ll need to assign them the “View media” permission.
Just go to People, Permissions and assign “anonymous user” the “View media” permission.
Part 2: How to Embed Media Entities
Creating media assets is useful but if you can’t embed them what’s the point of having them.
In this section we’ll embed assets directly into the editor using Entity Embed.
The Entity Embed module allows a site builder to create a button which lets an editor embed entities into a text area, hence the name Entity Embed. It can be used to embed any type of entity not just media bundles. So be creative, you could use it to embed event content types.
To begin, download the following modules:
Using Drush,
$ drush dl embed entity_embed $ drush en entity_embed
Create Embed Button
1. Go to Configuration and click on “Text editor embed buttons”.
2. Click on “Add embed button”.
3. Add Media into Label, select Entity from the “Embed type” and Media from the “Entity type” drop-down.
4. Once an entity type has been chosen, you can choose which media bundles can be embedded. If none are selected, then all are available.
And finally, upload a button icon which’ll be used in the editor. The default button is just an “E”.
Use this one from the media module: http://cgit.drupalcode.org/media/plain/images/media_embed_icon.png?h=8.x-1.x
At this point you should have two buttons, the Media button which we created and the Node button that comes default with the module.
Add Embed Button to Editor
We created the embed button, now we need to add it to the editor.
1. Go to Configuration, “Text formats and editors” and click Configure on the “Basic HTML” (or any text format) row.
2. Move the icon from the “Available buttons” into the “Active toolbar”.
From this:
To this:
Configure Filters
The next part we need to do is configure the filters.
We need to make sure a few things happen:
- Correct ordering of filters or the embedding may not work
- Making sure the “Allowed HTML tags” list accepts the tags used by Entity Embed
Configure “Allowed HTML tags” list
As soon as we added the button to the active toolbar, the following tags should be in the “Allowed HTML tags” list:
<drupal-entity data-entity-type data-entity-uuid data-entity-embed-display data-entity-embed-display-settings data-align data-caption data-embed-button>
Make sure these tags are in the text field. If not then embedding media assets WILL NOT WORK.
Enable “Display embedded entities”
Enable the “Display embedded entities” filter. This is required for the embedding to work.
Confirm Order of “Align images” and “Caption images”
The Entity Embed README.txt mentions if you’re using the “Align images” and “Caption images” filters, to order “Align images” before “Caption images”.
Problem with “Restrict images to this site” Filter
The “Restrict images to this site” Filter stops an image being displayed if you embed it and select an image style.
The filter stops a user from pointing to an image which is not hosted on the site. For example, if you’re Drupal site is hosted at my-drupal.com, then it won’t allow you to add an image such as <img src="http://random-site.com/image.jpg" />
, all your images need to be <img src="http://my-drupal.com/image.jpg" />
.
There is an open issue on drupal.org about it.
The workaround for now, unfortunately, is to remove the filter.
Once everything has been configured, make sure you click on “Save configuration” at the bottom of the page.
The filters list should look like this:
How to Embed Media into a Page
Now that the “Basic HTML” text format has been configured, we should be able to embed assets.
1. Go to Content, “Add content” and click on Article.
2. Click on the embed button and a pop-up should appear with an autocomplete field.
Search for the asset using its “Media name” and click on Next.
3. Select Thumbnail from “Display as”, select an image style, align and add a caption.
Then click on Embed.
4. Once embedded you should see the image on the right with the caption.
Save the page and you’re good to go.
Embedding YouTube Videos
In the section above it was easy to embed an image. You simply choose it, selected a thumbnail size and you’re done.
But if you try and embed a YouTube video using the “Video embed” bundle we created earlier. You’ll just see the video thumbnail and not an embedded player, not the desired result.
Create Media Bundle View Mode
The simple solution is to create a custom view mode for the “Video embed” media bundle. Let’s do this now.
1. Go to Structure, “Display modes”, “View modes” and click on “Add view mode”. Then click on Media.
2. Call this view mode Embed and click on Save.
3. Go to Structure, “Media bundles” and go to the “Manage display” page for the “Video embed” bundle.
4. Enable the Embed view mode which we just created by clicking on “Custom display settings” and select it, then click on Save.
5. Go to the view mode by clicking on it on the top left. Remove all the fields except “Video URL”. Make sure Video is selected from Format and “– Hidden –” from Label.
Then click on Save.
Now when you embed a video, select Embed from “Display as”. If you can’t see the new view mode clear the site cache.
Part 3: How to Browse Media Entities
When we chose an asset, we were given just a single autocomplete field.
This is not ideal. You shouldn’t expect your editors to remember the asset name. It’ll be better to have some sort of browser where we can see all the available media assets.
We’ll use Entity Browser to create browsing functionality and best of all, it integrates nicely with Entity Embed.
Let’s set this up now.
To begin, go download the following modules:
Using Drush,
$ drush dl entity_browser ctools $ drush en entity_browser ctools
How to Create an Entity Browser
There are two steps involved in creating a browser using the module.
First you’ll need to create a view using a display called “Entity browser”. This view will be used to list out all assets. Then you’ll need to configure an entity browser and select the created view.
Create Entity Browser View
1. Go to Structure, Views and click on “Add view”.
2. Fill out the “Add new view” form, using the values defined in Table 1.0 and click on “Save and edit”.
Table 1-0. Create a new view
Option | Value |
---|---|
View name | Entity browser |
Machine name | entity_browser |
Show | Media type of All sorted by Newest first |
Create a page | Unchecked |
Create a block | Unchecked |
3. Next to the Master tab click on “Add” and click on “Entity browser.
It’s important that you select the “Entity browser” display or you won’t be able to select this view when we’re configuring the actual browser.
Let’s change the view to a table so it looks a little better.
4. Click on “Unformatted list” next to Format.
5. From the pop-up, select Table and click on Apply.
At this point we’ve switched the view from a list to a table.
Now we need to add two fields: Thumbnail and “Entity browser bulk select form”.
6. Click on Add next to Fields, add the Thumbnail field.
This will display a thumbnail of the media asset.
7. Then add the “Entity browser bulk select form”.
This field is used to select the asset when browsing. It is a required field.
8. Reorder the fields so they’re as follows:
9. Once complete the preview should look like the image below:
10. Don’t forget to click on Save.
Create Entity Browser
Now that we’ve created the view, let’s configure the browser.
1. Go to Configuration, “Entity browsers” and click on “Add entity browser”.
2. Enter “Assets browser” into Label, select iFrame from “Display plugin” and Tabs from “Widget selector plugin”.
Leave “Selection display plugin” as “No selection display”.
Then click on Next
Do not select Model if you’re using the browser with Entity Embed it isn’t compatible (Issue #2819871).
3. On the Display page, configure a width and height if you like but do check “Auto open entity browser. This will save an extra click when embedding.
Then click on Next.
4. Just click Next on “Widget selector” and “Selection display”.
5. On the Widgets page, select “Upload images” from the “Add widget plugin”. Change the Label to “Upload images”.
6. Then select View from the drop-down.
7. From the “View : View display” drop-down, select the view which we created earlier.
If you can’t see your view, make sure you select “Entity browser” when configuring it:
8. Once configured the Widgets page should look like:
Configure Entity Embed to use Browser
Entity Embed now needs to be linked with the browser we created.
1. Go to Configuration, “Text editor embed buttons” and edit the embed button.
2. You should see a drop-down called “Entity browser”, select the browser you just created and click on Save.
Using the Entity Browser
Go into an article or page and click on the Entity Embed button.
You should now see a pop-up with two tabs: “Upload images and view.
From the “Upload images” tab, you can upload a new image and it’ll create an Image media bundle.
If you click on view, you’ll see all the media assets.
To embed an asset, just choose which one you want and click on “Select entities”.
How do you Add a YouTube Video from the Entity Browser Page?
I haven’t figured this out yet. If you know how, leave a comment.
Summary
Adding functionality to a Drupal 8 site to handle media assets can be done and it’s fairly solid. But as you can see there’s a lot of configuration involved. Hats off to the Drupal Media team for creating a flexible suite of modules. With the “Media in Drupal 8 Initiative” in the works, things are looking very promising.
Extra Resources
FAQs
Q: I created a new view mode but can’t see it when I embed an asset.
Clear the site cache.
Q: When I embed an image and select an image style all I see is a red cross.
Disable the “Restrict images to this site” filter.
Hi Ivan,
thank you for the comprehensive tutorial. I run into some problems. Maybe you can help me out. Background: Images with a custom field for the copyright notes. They should be used inline (CKEditor) an in fields (current image fields). All copyright notes of a node are collected in separate section under the page content.
– How can I use the Entity Browser in image fields and access the custom fields of the media? (We actual use image fields for a slider.) I tried to set Entity Browser in form display settings but I cannot access the custom fields from the output. It set only the image to the field.
– Can I get all media entities referenced on “current” node (inline and fields)? I could output the copyright field (media inserted in CKEditor) only near the image.
Thank you in advance.
Hi alexander,
– How can I use the Entity Browser in image fields and access the custom fields of the media? (We actual use image fields for a slider.) I tried to set Entity Browser in form display settings but I cannot access the custom fields from the output. It set only the image to the field.
Are you creating an entity browser in views? Is the copyright field on the media entity?
Then you should be able to add the field in views like any other.
– Can I get all media entities referenced on “current” node (inline and fields)? I could output the copyright field (media inserted in CKEditor) only near the image.
As far as I know media entity usage is not tracked like file entities are. If I’m wrong let me know 🙂
What you could do is reverse engineer the entity embed filter which searches for all “ ” tags. That’ll give you a list of media entities embedded in the node.
http://cgit.drupalcode.org/entity_embed/tree/src/Plugin/Filter/EntityEmbedFilter.php#n94
Cheers,
Ivan
Thanks for excellent tutorial!
Only one issue: when I upload an image via the Entity Browser, i receive this errormessage ‘The entity must be of type media’
However no problem when i try to upload the same image via content>media
Hi Steven,
I get the error when I use the “Upload” widget. Try using the “Upload images” widget instead.
Cheers,
Ivan
Thx! That did solve my problem.
It’s worth mentioning the Lightning distribution which gives you all of this preconfigured.
Thanks for the tip.
Hi
Thanks or the tutorial, just a couple of notes:
– Personally I found better to create different entity browsers for each type of media, so I have on y site one for images, one for documents and one for videos, each one with a view that only show the correct entities
– For being able to add a youtube video from the entity browser you need to add the entity_form widget and configure it to point to the video bundle and done
Hi huma2000,
Thanks for the tips, and thanks for the entity_form widget tip.
Cheers,
Ivan
Hi Ivan, thanks for this helpful post!
I need your help: It’s possible use the images with responsive images module? To get responsive images embedded.
Hi Luis,
Yes it should work.
Cheers,
Ivan
Hi Ivan, how can I do it?
I don’t have a tutorial on it. Just google “drupal 8 responsive images” and you’ll find some tutorials.
Hi Ivan – thanks for the great Drupal 8 content – I love it!
Question regarding Media Library and documents. We are using a version of Acquia’s Lightning, so we have quite a bit of this already in place; however, how do we use the Media Library for documents like PDFs?
When I try to include a PDF file (either already in the Media Library, or else uploaded) the options I get either embed the link as a PDF image icon, or else use the file name as the link text, or else use the Label as the link text — but not as an inline link that opens the PDF file. Rather, every one of them opens the entity page first, where the PDF document resides, which seems pretty useless for our visitors.
How do I fix this? I just want to be able to use Media to hold/upload such documents, and then correctly link to them as you’d expect in the WYSIWYG editor.
tl;dr – how does this work for linking to PDFs in CKEditor?
Hi Blaine,
I just tried the latest lightning and it redirected me to the actual file, not the media page. Maybe things have changed in the newest version.
You should be able to tweak the “embedded” view mode on the document media bundle:
Look at image below:
https://goo.gl/2sEJsk
Try changing the formatter to “generic file”
Cheers,
Ivan
Hi,
thanks for the good tutorial!
Is ist possible to use the asset browser we just created on fields, e.g. an Image? When I set it as widget in Form Display, selecting any media results gives the error “The entity must be of type file”. And since I am using paragraphs in my site, it is crucial to use the asset browser on fields.
Additionally, is it possible to replace the upload form with a form to add new media items? This reduces the amount of images not available in the library.
Thanks in advance!
Hi,
You can do it using an entity reference field with inline entity form (https://www.drupal.org/project/inline_entity_form) and the entity_form sub-module that comes with “Entity browser”.
So instead of using an Image field, use an entity reference field and set up inline entity form, then configure entity browser on the field. Most importantly: it must be an entity reference field.
I’m not sure about this. You’ll need to google around.
Cheers,
Ivan
Hi,
I tried this, but when I add a content reference field (for me there is no entity reference field, D8.3) and select the Inline Entity Form as widget, the field doesn’t even show up.
What am I doing wrong? Maybe you can add some instructions to the original tutorial
Hi,
Sorry you couldn’t get it working. I really don’t know why it’s not working.
I’ll write a tutorial about this soon.
Cheers,
Ivan
Hello Ivan,
Thanks for your (YouTube) tutorials on the topic op Media Asset Management! For a new site I implemented it and it works well. I create for a photo site a Media bundle with several added fields.
Now I wonder if it’s possible to add that Media bundle in any way to the Search module. It’s only possible to add and configure items of type Content and Users as a search page.
If it’s not possible to add Media entities to the Search module, can you advice an alternative Module or approach? Or do you know a source for more (background) information on this.
Thanks in advance,
Dirk van der Veen
Hi Dirk van der Veen,
You can’t use the core Search for Media entities. As you mentioned, it only works for Content and User entities.
You can, however, use Search API (https://www.drupal.org/project/search_api).
This module allows you to create search indexes for any entity type.
But it’s not as easy to set up as the Search module.
Maybe I’ll write a tutorial about this :). Thanks for the idea.
Cheers,
Ivan
Thanks Ivan for your quick and clear response.
Hi Ivan, great tutorial. Can you explain your decisions behind the “Filter processing order”. What is the rationale and consequences of using that order versus some other order?
Thanks in advance!
Hi Joel,
I just use the standard order that Drupal uses.
As mentioned in the tutorial, I adjust “Align images” and “Caption images” as recommended by Entity embed (http://cgit.drupalcode.org/entity_embed/tree/README.md#n39)
Every site will have a different order depending on other filters or custom filters.
Cheers,
Ivan
Hi,
Was It Possible To choose Multiple Media assets In Editor
Currently Getting Error cannot Choose more than one entity.
Hi Vignesh,
I’ve never tried selecting multiple items.
Sorry can’t help you there.
Cheers,
Ivan
Hi Ivan,
I’ve tried the Media Management portion of this several times now and keep running into the same issue of not getting a proper thumbnail in the Media list, I get a generic icon image instead. At first I thought the problem may have been being caused by my local environment setup, maybe a permissions problem or something, but I just tried it on a free Pantheon Dev account and encountered the same problem. I have followed the instructions very carefully and even watched your YouTube tutorial. I somewhat sure I’m setting every thing up correctly, do you have any suggestions?
Hi Rick,
What media entity plugin are you using? Image, Document?
Are you getting any errors? PHP or JavaScript?
Cheers,
Ivan
Hi Ivan,
I’m using the Media Entity API, version 8.x-1.6, with the Image Provider (Media Entity Image) version 8.x-1.2
No on-page errors but in the “recent log messages” I see an error that starts with… Notice: Trying to get property of no-object in Drupalmedia_entity_imagePluginMediaEntityTypeImage ->thumbnail()(line 208 of… and then goes on and on, a very long message.
Any ideas?
Hi Rick,
“Notice: Trying to get property of no-object in Drupalmedia_entity_imagePluginMediaEntityTypeImage ->thumbnail()(line 208 Notice: Trying to get property of no-object in Drupalmedia_entity_imagePluginMediaEntityTypeImage ->thumbnail()(line 208”.
^ This is the problem. It’s in the thumbnail method.
Found this bug, https://www.drupal.org/node/2780553.
I have no idea why it’s happening, but others do have the same issue. Look in the above link.
Cheers,
Ivan
How would I receive a token of the video id of a youtube video that was added via video_embed_field?
Hi Darko,
Sorry don’t know, never done it. Best to ask in the video_embed_field issue queue (https://www.drupal.org/project/issues/video_embed_field?categories=All).
Cheers,
Ivan
Thanks for the tutorial!
When using embed_entity for images, the Media Bundles -> Manage Display -> Format has no effect (because embed formats are determined by the allowed Entity Embed Display plugins… not field formatters). So, how can you use Colorbox for embedded images?
Hi Frost,
I dan’t have much experience using Colorbox. Cant’ help you there.
Cheers,
Ivan
Same question – anybody found out how to use Colorbox for embedded entities (images)?
Hi,
I haven’t used Colorbox.
Cheers,
Ivan
Hi Ivan
Thank you for the walk through for creating media bundles, assets and embedding, it is really useful. Of course there is the issue
with not displaying the embedded video, the solution below has solved it, in a way.
Utilize display modes.
Step 1 Create a view mode for your Media :
———————————————-
Structure /Display modes / Add a new view mode. (video embed)
Step 2 Activate this view mode for your media type :
——————————————————-
Structure / Media bundles / Your media bundles / Manage display, activate the checkbox in the bottom page (custom layout settings)
and Save.
Step 3 Clear you cache :
—————————
This is a very important step and the next step won’t work without clearing your cache.
Configuration / Content editing / Text editor embed buttons.
—————————————————————————–
You should now see the view mode you created in step 1, adjust the fields for displaying embedded video.
You will notice now in the “Allowed Entity Embed Display plugins” section are Entity id, label, thumbnail, video embed (select this).
I hope this helps Ivan, as it helped me complete this excellent guide. remmeber drush cr after new view mode created, everytime.
Here is the link to where i found the method. Thanks to Falcox (https://www.drupal.org/u/falcox https://www.drupal.org/node/2817891
Cheers Leo
Hi Leo,
Thanks for the detailed comment. 🙂
Cheers,
Ivan
Thanks for the concise how-to.
Is it possible to define different sub-directories for image/file uploads? Perhaps using a taxonomy term token? i.e., if the image was uploaded from a page in the “About” section, it would be stored in an “about” sub-directory.
If so, would that photo still be usable in other areas of the site?
Hi Don,
Look at using “File field paths” (https://www.drupal.org/project/filefield_paths).
This allows you to specify the upload path using tokens, i.e.,
[node:id]/[taxonomy:name]
for example.If so, would that photo still be usable in other areas of the site?
Yes, you can view any uploaded images throughout the site.
Cheers,
Ivan
Thanks! We’ll look at implementing.
thanks a lot for the work
there is a problem with the image display when embedded on ckeditor.
showing just an icon of absent image
this is because in a site where I m forced to store uploaded images in private folder.
in setting of the Embed buttons
Upload destination
Public files
x-Private files
so is there any way to do it even using Private files
thanks
Hi Mhamed,
I’ve never set up Media Entity on a site with a private file system. Try asking in the issue queue.
Cheers,
Ivan
People have been asking for that for a long time. They way I did it was to upload it to prod and spin up a new local dev site to work from. Have had no problems after I did that.
Hello, upgrade please this tutorial for >8.5.x core thanks 🙂
Working on it. 😉
it looks like the media_entity_image is not installing after the upgrade. how soon can you release the updated tutorial?
Thank you! Peace.
Still working it.
media_entity_image is no longer required. It comes with Drupal 8.5 core.
Could you please describe a quick summary of what’s different with 8.5 so I know what to look out for?
Hi Vayu,
An updated tutorial is coming out next week.
Configuring Entity embed and Entity browser is exactly the same. Just make sure you download the 8.x-2.0-alpha2 version of Entity browser.
Media Entity is no longer required, instead use the core Media module.
Below is an excerpt from the updated tutorial:
———
What’s the Difference Between Media Entity and Media
The biggest difference between the two modules is that the API has changes. Any media provider module for Media Entity such as Media entity Instagram or Media entity Twitter need to be updated to use the new API. A lot of these modules now have a 8.x-2.0 version which only works with core Media. So if you’re going to use a media provider module read the project page.
If you want to see a technical explanation of the changes go to the “Moved a refined version of the contributed Media entity module to core as Media module” change record on drupal.org.
———
An updated version of this tutorial has been published: https://www.webwash.net/?p=4849
Perhaps it would be best to specify the version of Drupal you are writing your tutorial about _when you write it_, considering how often Drupal changes its core functionality. Tutorials like this are worse than useless because they can create confusion and frustration for readers and newbies. For example, when they state they are for “Drupal 8” and you have to sift through nearly 50 comments to find the statement that an updated tutorial has been posted and even THAT one says “for Drupal 8.5+”. No, it’s not. It’s for whatever version of Drupal you used in development the tutorial (and perhaps a few versions prior). If you want these tutorials to be helpful for the audience they are targeting, please specify the exact version you used and the known compatible prior versions.
I was overly harsh when I said “Tutorials like this are worse than useless.” Obviously they are great until they are obsolete, and _then_ they become troublesome. All we need is a bit more specificity. And I also forgot to say thanks for taking the time to post helpful information. I’ve certainly benefited from what you are putting out.
The first line of this tutorial says “Read Managing Media Assets using Core Media in Drupal 8 to learn how to add media management functionality into a Drupal 8.5 site using the core Media module.” with a link to the latest version.
What more do you want?
I put in a lot of time and effort into these FREE tutorials and if you’re unhappy or it’s not up to your standards then look else where.
Point taken. I posted a follow up comment already to that effect. I should have been kinder in my critique, and should have indicated my gratitude up front. I still think that tutorial bloggers should use better versioning notation. It would greatly enhance the value of their posts.
It takes hours or DAYS to write up these tutorials. We owe Ivan a lot. I hope this does not discourage him from sharing. This tutorial saved me days of research and frustration when it came out. Thank you so much Ivan!
Jamie, while we are sharing advice on how other people post on the web, I suggest that you read all the comments in a thread before just staring to follow the instructions. The details people add in the comments can give valuable hints and clues as to whether the contents of a tutorial are right for your individual situation. Its on the consumer to read the fine print.
I wouldn’t expect a simple suggestion to add the version to his posts to discourage the author. That would be weird.
I did read the comments, of course, and even the line Ivan referred to at the top. The issue with the link at the top is that it doesn’t mention that this article is obsolete as regards the latest D8 versions. I figured I was still on a topical article and read on. It’s only at the bottom of the comments, nearly 50 of them, before the topic of obsolescence comes up.
I’m not trying to be a jerk here (although I came off like one in the first post, unfortunately). I’m sincerely recommending that the simple inclusion of the exact version that is used to create the tutorial being posted, at the time it is posted, would be of immense value for both early and later readers.
And I should most definitely say that I owe a lot to Ivan, as well. His linked article DID get me on track with an understanding of the current Media situation, which is much more than I can say for anything in the official D8 documentation which is rife with old/misleading information. Were it not for these articles, I’d still be tearing my hair out.
Thank you so much for this post! I even found it helpful in February 2019. I found it through Google, so I don’t know if there is an updated version somewhere for later versions of drupal, but for those who find this post the way I did, there are just a couple changes to use these instructions. The Entity module is now a part of Drupal core see Ivan’s post from May 3, 2017), so attempting a Composer install of drupal/entity will fail. Also, media bundles seem to have been renamed Media types.
Thanks again for the article!
Hi Ivan, thank you for your tutorials!
I have a problem: when I embed a media I can’t select the display mode, in fact the tab “Display as” won’t show up, and I can’t figure out why! My entity has several displays and it happens event if I embed a content node.
Any Idea of what could be the solution?
Thank you so much!
Hi Valeria,
First of all, make sure you have a few view modes. Second, on the entity embed button configuration page, make sure you allow the user to select the different view modes.
Cheers,
Ivan