You want to allow your content editors to easily retrieve and integrate media, images, videos, sounds, presentations from third-party platforms? The Media entity suite has an extra string to its bow with the URL embed module. This module uses the PHP Embed library, and allows you to simply retrieve from a url a media from a third-party platform like Twitter, YouTube, Instagram, SoundCloud, Spotify, Vimeo, Slideshare, etc. To mention only the best known.
This module allows you to integrate a remote media within a text field or from a dedicated link field type. Let us discover how this module works, very simply besides.
Installing the module
You can install this module with Composer (composer require drupal/url_embed ~1.0). This method will download the module, as well as its dependencies, namely the Embed module and the PHP Embed library. If you want to install it from drush, or by downloading its archive, you will have to download these dependencies, and in particular place the PHP library in the /vendor directory of your site.
Configuration and use with CKEditor
Once installed, this module provides an embed button by default. This button will be available later in the CKeditor options for the text formats using it. You can customize this button, change its icon, and add as many as you need.
This button will then be available in the available CKeditor buttons.
To enable media integration, drag the previously created button into the CKeditor active bar. In the example below we configure the full HTML text format.
We activate too the two filters provided by the URL embed module.
The first filter Convert URLs to URL embeds automatically converts a link pasted directly into the text body, and transform it into an url that can be processed by the second filter.
The second filter Display embedded URLs allows to transform the link added with the dedicated media dialog box.
In order to automatically transform the pasted urls directly into the body, the first filter must be placed before the second in the filter processing order settings applied to the text format.
If you have enabled the Limit allowed HTML and correct faulty HTML filters, then the following tag should be added to the Allowed Tags input field:
As shown in the capture below.
You also have the option of filtering the type of url that you want to convert automatically. For example, if you want only Twitter urls to be converted automatically, you can enter https://twitter.com in this field. Leave it empty to allow any type of urls.
And your text format is configured. All you have to do now is to insert media using links, either with the button and its dialog box.
Or simply by copying / pasting the url into the body of the text.
And the corresponding rendering
Using Embed URLs with fields
The use of this module with Link fields is even easier.
After you add a Link field to a content type, you simply configure its display mode and select the Embedded URL format.
And you just need to enter any supported url in the field.
For the following rendering
Embed URL and Media Entity Suite
The Media Entity suite already includes many extensions to add many media types (image, video, document, etc.) to a structured catalog, as well as remote media such as Twitter, Slideshare, Soundcloud, Spotify, Youtube, Dailymotion, Etc.
URL Embed is a lighter alternative, but also with fewer options, for those who want to easily insert different types of remote media, without wanting to set up an internal media library system. Although in alpha version, the module is quite operational, despite some small bugs on certain types of media or urls (Some providers (Facebook, Twitter) badly rendered in editor and Some URLs are rendered correctly only the first time), and still requires some minor improvements before it can be available in stable version. A module to keep in its favorite module.