The Video Filter module allows you to easily embed videos into Drupal sites using a simple token ([video:url]). Setting up the module is pretty straight forward. All you have to do is enable the filter in a desired text format, adjust the order of the existing filters, and you’re done.
The embed code for YouTube and many other video sites is an
iframe HTML tag. By default, Drupal will filter out any
iframe HTML code if anonymous and authenticated users use the Filtered HTML text format. Bottom line is you don’t want users to simply paste in
iframe HTML code into Drupal.
By using Video Filter users can easily embed videos from YouTube by pasting in
[video:URL] instead of an
iframe. This is a perfect solution for a community website built in Drupal, especially if you allow users to participate in a forum.
It’s important to understand that this module is not a replacement for Media module. If you’re looking for a proper media solution, then look at Media or Scald.
Also, here are two other modules that will help you embed videos: Video Embed Field and oEmbed.
In this tutorial, we’ll configure Video Filter on the “Filtered HTML” text format. The module also comes with a button that allows you to add tokens easily using Wysiwyg editors, we’ll setup this button in CKEditor.
Before we can begin, go download and install Video Filter.
If you use Drush, run the following commands:
$ drush dl video_filter
$ drush en video_filter
Configure Video Filter on “Filtered HTML” Text Format
The simplest way to use this module is to add it to a text format. In this section, we’ll setup the filter on the Filter HTML text format.
1. Go to Configuration, “Text formats” and click on configure in the “Filter HTML” row.
2. Check the “Video Filter” filter so that it gets added.
3. Now comes the tricky part; reorder the filter so that it’s after “Limit allowed HTML tags” and before “Convert URLs into links”. This is important and may take a bit of experimenting.
4. Once you’ve reordered the filter click on “Save configuration”.
You can also configure some of the filter settings like default width and height, as well as autoplay and more. Click on the “Video Filter” tab in the filter settings area to configure it.
That’s all for the basic setup, now go to Content, “Add content” and click on Article.
Enter in a title and paste in the following token:
Once you’ve saved the article, you’ll see an embedded YouTube video.
You can even configure certain video settings directly from the token.
Here are all the available settings:
[video:url width:X height:Y ratio:X/Y align:left/right autoplay:1/0]
Video Filter Button in CKEditor
The module also ships with a Video Filter button that integrates it with a few WYSIWYG editors. I’ll show you how to add the button to CKEditor using Wysiwyg. I won’t go through the steps of setting everything up, or this tutorial will be huge. I’ll assume you already have a basic setup of CKEditor.
Go to Configuration, “Wysiwyg profiles” and edit an existing profile. Click on the “Buttons and plugins” field-set and check the “Video filter” button, then click on Save.
Now go to Content, “Add content” and Article.
Click on the “Video filter” button, fill out the form and then click Insert.
The integration with Wysiwyg does not work like the Media module. You won’t see a preview of the video, it’ll just display the token.
Now, save the form and you should see an embedded video.
Video Filter is great because it’s a quick and simple solution for embedding videos into Drupal. The biggest benefit to using this module is the ability to allow users to embed videos without compromising your site security.
If you have any questions, please leave a comment.
6 thoughts on “How to Embed Videos using Video Filter in Drupal 7”
I believe you will find that Video Filter will not delivery what it is designed to when the Drupal site is running with HTTPS. I need a solution that interoperates with HTTPS. Perhaps Scald?
I would first test out this patch: https://drupal.org/node/786774#comment-7565803
You can try Scald, but if it hardcodes the schema, “http://” you’ll have the same HTTPS issues.
The patch mentioned above converts the URLs in the module from “http://www.youtube.com/v/” to “//www.youtube.com/v/”.
I had already tried that specific patch. No cigar, unfortunately, because otherwise the module is very nice.
Scald is next on the list.
hi, thanks for tutorial. could it be possible to write link to text field and show the video in iframe no in editor.
You can do this with a text field and some custom code or you could use the “Video Embed Field” module. (https://drupal.org/project/video_embed_field)
Unless I’m missing some important detail, just Video Embed Field.
Great tutorial, this is exactly what I was looking for. It is quite strange that the order of the filters is not mentioned in the official description of the module!