Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/support twitter videos #85

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Embed twitter videos instead of linking to them
djmaze committed Mar 15, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit fdc2c639c7fd6dfbd4239da3391a067126fb65e4
20 changes: 19 additions & 1 deletion lib/embed/tweet.js
Original file line number Diff line number Diff line change
@@ -110,6 +110,15 @@ class Tweet extends Observable(Embed) {
m.imageUrl = `${this.url}-images-${idx}`
if (m.type === 'video') {
m.targetUrl = m.expanded_url
m.video = {
imageUrl: m.imageUrl,
videoUrls: m.video_info.variants.map((m, idx) => {
return {
url: m.url,
contentType: m.content_type
}
})
}
} else {
m.targetUrl = m.imageUrl
}
@@ -164,7 +173,16 @@ class Tweet extends Observable(Embed) {
{{#hasMedia}}
<section class="media-{{media.length}}" id="media">
{{#media}}
<a target="_blank" href="{{targetUrl}}"><img src="{{imageUrl}}"></a>
{{#video}}
<video poster="{{imageUrl}}" controls preload="none">
{{#videoUrls}}
<source src="{{url}}" type="{{contentType}}"></source>
{{/videoUrls}}
</video>
{{/video}}
{{^video}}
<a target="_blank" href="{{targetUrl}}"><img src="{{imageUrl}}"></a>
{{/video}}
{{/media}}
</section>
{{/hasMedia}}
2 changes: 1 addition & 1 deletion lib/embed/tweet.scss
Original file line number Diff line number Diff line change
@@ -111,7 +111,7 @@ $quoteLineWidth: 4px;
}
}

img {
img, video {
max-width: 100%;
width: 100%;
height: 100%;