Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mastofe
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Haelwenn
mastofe
Commits
478ca39e
Unverified
Commit
478ca39e
authored
Feb 15, 2018
by
Eugen Rochko
Committed by
GitHub
Feb 15, 2018
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
After click to embed video, autoplay it (#6480)
parent
f7765acf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
1 deletion
+24
-1
app/javascript/mastodon/features/status/components/card.js
app/javascript/mastodon/features/status/components/card.js
+24
-1
No files found.
app/javascript/mastodon/features/status/components/card.js
View file @
478ca39e
...
...
@@ -30,6 +30,29 @@ const trim = (text, len) => {
return
text
.
substring
(
0
,
cut
)
+
(
text
.
length
>
len
?
'
…
'
:
''
);
};
const
domParser
=
new
DOMParser
();
const
addAutoPlay
=
html
=>
{
const
document
=
domParser
.
parseFromString
(
html
,
'
text/html
'
).
documentElement
;
const
iframe
=
document
.
querySelector
(
'
iframe
'
);
if
(
iframe
)
{
if
(
iframe
.
src
.
indexOf
(
'
?
'
)
!==
-
1
)
{
iframe
.
src
+=
'
&
'
;
}
else
{
iframe
.
src
+=
'
?
'
;
}
iframe
.
src
+=
'
autoplay=1&auto_play=1
'
;
// DOM parser creates html/body elements around original HTML fragment,
// so we need to get innerHTML out of the body and not the entire document
return
document
.
querySelector
(
'
body
'
).
innerHTML
;
}
return
html
;
};
export
default
class
Card
extends
React
.
PureComponent
{
static
propTypes
=
{
...
...
@@ -92,7 +115,7 @@ export default class Card extends React.PureComponent {
renderVideo
()
{
const
{
card
}
=
this
.
props
;
const
content
=
{
__html
:
card
.
get
(
'
html
'
)
};
const
content
=
{
__html
:
addAutoPlay
(
card
.
get
(
'
html
'
)
)
};
const
{
width
}
=
this
.
state
;
const
ratio
=
card
.
get
(
'
width
'
)
/
card
.
get
(
'
height
'
);
const
height
=
card
.
get
(
'
width
'
)
>
card
.
get
(
'
height
'
)
?
(
width
/
ratio
)
:
(
width
*
ratio
);
...
...
Haelwenn
@lanodan
mentioned in commit
d9a92d50
·
Sep 14, 2018
mentioned in commit
d9a92d50
mentioned in commit d9a92d504053568ce424f23667c7dc6121d9b20d
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment