In Part 1 of this series, I showed an easy system for including oEmbed rich content in a WYSIWYG, including reusing that content. In this installment I'll step through how to set it all up in Drupal 7.
First of all, in order to use Asset module you can't use WYSIWYG module - you need to use CKeditor module. CKeditor module is great though - you have more control of your editor configuration than with WYSIWYG module.
Install Asset module from drupal.org: I typically enable only Asset, Asset document, and Asset image, out of the submodules in the Asset package.
Similar to how Media module works, you need to enable the Asset filter on your input format(s). On the CKeditor settings make sure you enable the Media Asset plugin.
Also add oEmbed module and enable its submodules oEmbed Field oEmbed Embedly. Add an API key to the oEmbed Embedly configuration.
Create a new Asset type (Structure: Asset Types: Add Asset Type) called 'Embed' and pick an icon for it. At 'Manage Fields' add a link field, and at 'Manage Display' choose oEmbed for the display formatter of the link (for both Default and Full Size modes). Go back the CKeditor settings and drag your new button into your WYSIWYG configuration.
You may also want to do some templating and styling: I overrode the oembed.tpl.php from oEmbed to not show an extra title link to the embed. I also overrode the asset.tpl.php to likewise not show the Asset title.
Media module has a nice ability to be used as a widget for a file field, letting you reuse media from your library or add new media. So how can we get a similar feature using our beloved Asset module library? Because Asset is an entity type, you can create entity reference fields to reuse assets. A great widget for entity reference fields is Inline Entity Form. This lets you add a new or existing asset of any type as a field. We contributed a patch for Asset to add support for Inline Entity Form, which is in the latest Dev release of Asset module.
Of course not. This is the kind of setup you should do in a starter-kit: an install profile that you use for every site. We've added it to our Bear Starter-kit, which you're welcome to fork.
If you're not ready to make the Asset module plunge, you can still use oEmbed. If you like Scald, you can do a similar setup using this Embedly Scald module. And if you use Media module you can use the Media oEmbed submodule (included in oEmbed module).
Stay tuned for Part 3 in which we report on what we've done to make it easy to embed 3rd party content in Drupal 8.
Jody is a full stack Drupal expert. She does technical architecture, strategy, development, consulting, and developer training. Jody has worked on hundreds of Drupal projects since she began as a freelancer in 2006 and co-founded Zivtech in 2008. Jody grew up in the Philadelphia area and graduated from Harvey Mudd College in California in 2000.
View the discussion thread.
Tell us about your project