Skip to content

Commit

Permalink
add config to mdx_video extension to use youtube-nocookie.com for iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
bhemmer committed Jul 16, 2020
1 parent 8cdc30c commit 07316b7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion martor/extensions/mdx_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def __init__(self, **kwargs):
'yahoo_height': ['351', 'Height for Yahoo! videos'],
'youtube_width': ['560', 'Width for Youtube videos'],
'youtube_height': ['315', 'Height for Youtube videos'],
'youtube_nocookie': [False, 'Use youtube-nocookie.com instead of youtube.com']
}

# Override defaults with user settings
Expand Down Expand Up @@ -97,7 +98,10 @@ def handleMatch(self, m):
class Youtube(markdown.inlinepatterns.Pattern):

def handleMatch(self, m):
url = '//www.youtube.com/embed/%s' % m.group('youtubeid')
if self.ext.config['youtube_nocookie'][0]:
url = '//www.youtube-nocookie.com/embed/%s' % m.group('youtubeid')
else:
url = '//www.youtube.com/embed/%s' % m.group('youtubeid')
width = self.ext.config['youtube_width'][0]
height = self.ext.config['youtube_height'][0]
return render_iframe(url, width, height)
Expand Down

0 comments on commit 07316b7

Please sign in to comment.