FEATURE: Autoplay oneboxed twitter GIF media

This commit is contained in:
David Taylor 2020-08-17 23:56:41 +01:00
parent 5f7839f0a4
commit eb981b8fbb
No known key found for this signature in database
GPG Key ID: 46904C18B1D3F434
1 changed files with 18 additions and 3 deletions

View File

@ -33,14 +33,29 @@ class TwitterApi
width = m['sizes']['large']['w']
height = m['sizes']['large']['h']
attributes =
if m['type'] == 'animated_gif'
%w{
loop
muted
autoplay
disableRemotePlayback
disablePictureInPicture
}
else
%w{
controls
playsinline
}
end.join(' ')
result << <<~HTML
<div class='tweet-images'>
<div class='aspect-image-full-size' style='--aspect-ratio:#{width}/#{height};'>
<video class='tweet-video' controls playsinline
<video class='tweet-video' #{attributes}
width='#{width}'
height='#{height}'
poster='#{m['media_url_https']}'
#{'loop' if m['type'] == 'animated_gif'}>
poster='#{m['media_url_https']}'>
<source src='#{url}' type="video/mp4">
</video>
</div>