Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F32914098
PhabricatorRemarkupRuleYoutube.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
1020 B
Subscribers
None
PhabricatorRemarkupRuleYoutube.php
View Options
<?php
/**
* @group markup
*/
final
class
PhabricatorRemarkupRuleYoutube
extends
PhutilRemarkupRule
{
public
function
apply
(
$text
)
{
$this
->
uri
=
new
PhutilURI
(
$text
);
if
(
$this
->
uri
->
getDomain
()
&&
preg_match
(
'/(^|
\.
)youtube
\.
com$/'
,
$this
->
uri
->
getDomain
()))
{
return
$this
->
markupYoutubeLink
();
}
return
$text
;
}
public
function
markupYoutubeLink
()
{
$v
=
idx
(
$this
->
uri
->
getQueryParams
(),
'v'
);
if
(
$v
)
{
$youtube_src
=
'https://www.youtube.com/embed/'
.
$v
;
$iframe
=
'<div class="embedded-youtube-video">'
.
phutil_tag
(
'iframe'
,
array
(
'width'
=>
'650'
,
'height'
=>
'400'
,
'style'
=>
'margin: 1em auto; border: 0px;'
,
'src'
=>
$youtube_src
,
'frameborder'
=>
0
,
),
''
).
'</div>'
;
return
$this
->
getEngine
()->
storeText
(
$iframe
);
}
else
{
return
$this
->
uri
;
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Nov 17, 9:23 PM (6 h, 30 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
34/fd/a0449959dfb61e4c3abacc0500a5
Attached To
rPHAB Phabricator
Event Timeline
Log In to Comment