mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 16:15:13 +00:00
basic support for video alt-text
This commit is contained in:
parent
485935ffe6
commit
b73e9f7c35
2 changed files with 29 additions and 2 deletions
|
@ -168,7 +168,28 @@ function videowithopts($match)
|
|||
$poster = 'poster="' . (($zrl) ? zid($matches[1]) : $matches[1]) . '"';
|
||||
}
|
||||
|
||||
return '<video ' . $poster . ' controls="controls" preload="none" src="' . str_replace(' ', '%20', $link) . '" style="width:100%; max-width:100%;"><a href="' . str_replace(' ', '%20', $link) . '">' . $link . '</a></video>';
|
||||
$x = preg_match("/title='(.*?)'/ism", $attributes, $matches);
|
||||
if ($x) {
|
||||
$title = $matches[1];
|
||||
}
|
||||
|
||||
$x = preg_match("/title=\"\;(.*?)\"\;/ism", $attributes, $matches);
|
||||
if ($x) {
|
||||
$title = $matches[1];
|
||||
}
|
||||
|
||||
// This regex permits backslash-quote escapes inside the alt text.
|
||||
$x = preg_match('/title="([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"/ism', $attributes, $matches);
|
||||
if ($x) {
|
||||
$title = $matches[1];
|
||||
}
|
||||
$title = (($title)
|
||||
? 'title="' . htmlspecialchars(str_replace('\\"', '"', $title), ENT_QUOTES, 'UTF-8', false) . '"'
|
||||
: '');
|
||||
|
||||
|
||||
|
||||
return '<video ' . $poster . $title . ' controls="controls" preload="none" src="' . str_replace(' ', '%20', $link) . '" style="width:100%; max-width:100%;"><a href="' . str_replace(' ', '%20', $link) . '">' . $link . '</a></video>';
|
||||
}
|
||||
|
||||
// [noparse][i]italic[/i][/noparse] turns into
|
||||
|
|
|
@ -4730,7 +4730,13 @@ class Activity
|
|||
}
|
||||
if (array_key_exists('type', $a) && stripos($a['type'], 'video') !== false) {
|
||||
if (self::media_not_in_body($a['href'], $item['body'])) {
|
||||
$item['body'] .= "\n\n" . '[video]' . $a['href'] . '[/video]';
|
||||
if (isset($a['name']) && $a['name']) {
|
||||
$alt = htmlspecialchars($a['name'], ENT_QUOTES, 'UTF-8', false);
|
||||
$alt = str_replace(['[', ']'], ['[', ']'], $alt);
|
||||
$item['body'] .= "\n\n" . '[video title="' . $alt . '"]' . $a['href'] . '[/img]';
|
||||
} else {
|
||||
$item['body'] .= "\n\n" . '[video]' . $a['href'] . '[/video]';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (array_key_exists('type', $a) && stripos($a['type'], 'audio') !== false) {
|
||||
|
|
Loading…
Reference in a new issue