Custom Django template tags to simplify embedding Youtube videos and thumbnails.
Uses HTML and CSS code from Embed Responsively.
Install via pip
$ pip install django-youtube-tags
or download the source, enter the directory, and
$ sudo python setup.py install
Make sure to include django-youtube-tags
in your Django settings' INSTALLED_APPS
:
INSTALLED_APPS = [
'django-youtube-tags',
...
Lastly, make sure to declare {% load youtube %}
at the top of the Django template(s) where you plan to use this library.
video_id
is the URL segment that uniquely identifies the YouTube video.
include_style
is True
by default. When True
, it includes the CSS style inline. Depending on your situation, this may not be a good practice. The better practice may be to place {% youtube_style %}
inside your template's <head>
section and then use {% youtube_embed %}
(see below)
Same as {% youtube %}
with include_style
set to False
Renders needed CSS classes inside a <style>
tag.
<img alt="Rogue One" src="{% youtube_thumb 'Wji-BZ0oCwg' %}">
Generates the thumbnail source URI