Cheetah
Main Page
Related Pages
Namespaces
Namespace List
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Variables
$
a
b
c
d
e
f
h
i
l
m
o
p
r
s
t
u
v
x
Files
File List
File Members
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Functions
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Variables
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Pages
plugins
htmlpurifier
standalone
HTMLPurifier
Filter
YoutubeIframe.php
Go to the documentation of this file.
1
<?
php
2
3
class
HTMLPurifier_Filter_YoutubeIframe
extends
HTMLPurifier_Filter
4
{
5
public
$name
=
'YouTubeIframe'
;
6
7
public
function
preFilter
(
$html
,
$config
, $context)
8
{
9
if
(strstr(
$html
,
'<iframe'
) && (strstr(
$html
,
'youtube.com'
) || strstr(
$html
,
'youtu.be'
) || strstr(
$html
,
'youtube-nocookie.com'
))) {
10
$html
= str_ireplace(
"</iframe>"
,
""
,
$html
);
11
if
(preg_match_all(
"/<iframe(.*?)>/si"
,
$html
, $result)) {
12
foreach
($result[1]
as
$key => $item) {
13
preg_match(
'/width="([0-9]+)"/'
, $item, $width);
14
$width = $width[1];
15
preg_match(
'/height="([0-9]+)"/'
, $item, $height);
16
$height = $height[1];
17
if
(preg_match(
'/((\/\/www\.youtube\.com\/embed\/)|(\/\/www\.youtube-nocookie\.com\/embed\/)|(\/\/www.youtube.com\/v\/))([a-zA-Z0-9_-]+)/'
, $item, $id)) {
18
$id = $id[5];
19
$sProto = 0 == strncmp(
'https'
, CH_WSB_URL_ROOT, 5) ?
'https'
:
'http'
;
20
$html
= str_replace($result[0][$key],
'<img class="YouTubeIframe" width="'
. $width .
'" height="'
. $height .
'" src="'
. $sProto .
'://www.youtube-nocookie.com/embed/'
. $id .
'?rel=0">'
,
$html
);
21
}
22
}
23
}
24
}
25
return
$html
;
26
}
27
28
public
function
postFilter
(
$html
,
$config
, $context)
29
{
30
$post_regex =
'#<img class="YouTubeIframe" ([^>]+)>#'
;
31
$html
= preg_replace_callback($post_regex, array($this,
'postFilterCallback'
),
$html
);
32
return
$html
;
33
}
34
35
protected
function
postFilterCallback
($matches)
36
{
37
return
'<iframe frameborder="0" allowfullscreen '
. $matches[1] .
'></iframe>'
;
38
}
39
}
$config
$config
Definition:
Filter.ExtractStyleBlocks.txt:33
php
HTMLPurifier_Filter
Definition:
HTMLPurifier.standalone.php:5134
HTMLPurifier_Filter_YoutubeIframe\postFilter
postFilter($html, $config, $context)
Definition:
YoutubeIframe.php:28
HTMLPurifier_Filter_YoutubeIframe
Definition:
YoutubeIframe.php:4
HTMLPurifier_Filter_YoutubeIframe\preFilter
preFilter($html, $config, $context)
Definition:
YoutubeIframe.php:7
HTMLPurifier_Filter_YoutubeIframe\$name
$name
Definition:
YoutubeIframe.php:5
$html
$html
Definition:
Filter.ExtractStyleBlocks.txt:37
HTMLPurifier_Filter_YoutubeIframe\postFilterCallback
postFilterCallback($matches)
Definition:
YoutubeIframe.php:35
as
as
Definition:
Filter.ExtractStyleBlocks.Escaping.txt:10
Generated by
1.8.20