Add BB tag for YouTube videos to news and forum. Use with the video id (after v= in URL) ex. [youtube]wK0w0x62PjA[/youtube]

This commit is contained in:
Martin Nylind 2014-10-23 15:37:17 +02:00
parent 3265ba6c99
commit 5af3051c36
3 changed files with 24 additions and 0 deletions

View File

@ -23,6 +23,7 @@ function TransformToBBCode($string) {
'[link={$1}]{$2}[/link]' => '<a href="$1" target="_BLANK">$2</a>',
'[color={$1}]{$2}[/color]' => '<font color="$1">$2</font>',
'[*]{$1}[/*]' => '<li>$1</li>',
'[youtube]{$1}[/youtube]' => '<div class="youtube"><div class="aspectratio"><iframe src="//www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe></div></div>',
);
foreach ($tags as $tag => $value) {

View File

@ -63,6 +63,7 @@
'[link={$1}]{$2}[/link]' => '<a href="$1" target="_BLANK">$2</a>',
'[color={$1}]{$2}[/color]' => '<font color="$1">$2</font>',
'[*]{$1}[/*]' => '<li>$1</li>',
'[youtube]{$1}[/youtube]' => '<div class="youtube"><div class="aspectratio"><iframe src="//www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe></div></div>',
);
foreach ($tags as $tag => $value) {
$code = preg_replace('/placeholder([0-9]+)/', '(.*?)', preg_quote(preg_replace('/\{\$([0-9]+)\}/', 'placeholder$1', $tag), '/'));

View File

@ -628,3 +628,25 @@ hr {
background-color: green;
border: 1px solid black;
}
/* ///////////\/\\\\\\\\\\\
// Znote YOUTUBE BB \\
///////////\/\\\\\\\\\\\ */
div.youtube {
width: 100%;
max-width: 560px;
}
div.aspectratio {
width: 100%;
padding-bottom: 56.25%; /* 16:9 */
position: relative;
}
div.aspectratio > iframe {
position: absolute;
top: 0; bottom: 0; left: 0; right: 0;
width: 100%;
height: 100%;
}