youtube fixes

This commit is contained in:
j 2021-11-19 15:35:56 +01:00
parent 14679dc0a5
commit e7192e6bbd

View file

@ -37,7 +37,10 @@ class Event(models.Model):
elif '<' in self.media: elif '<' in self.media:
html = self.media html = self.media
else: else:
html += '<iframe src="%s"></iframe>' % self.media url = self.media
if 'youtube.com/watch' in url:
url = url.replace('/watch', '/embed')
html += '<iframe src="%s" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>' % url
if self.media_caption: if self.media_caption:
html = '<figure>%s<figcaption>%s</figcaption></figure>' % (html, self.media_caption) html = '<figure>%s<figcaption>%s</figcaption></figure>' % (html, self.media_caption)
return html return html