Added some details

This commit is contained in:
Pablo Ferreiro 2023-04-02 20:14:48 +02:00
parent 4188fcf064
commit aadfeccab1
No known key found for this signature in database
GPG key ID: 41FBCE65B779FA24
10 changed files with 48 additions and 5 deletions

View file

@ -91,9 +91,19 @@ class Wrappers {
return UrlBuilder::download($url, $username, $id, $watermark);
});
$latte->addFunction('bool_to_str', function (bool $cond): string {
return $cond ? 'yes' : 'no';
});
// Add URLs to video descriptions
// TODO: Make it work with unicode characters such as emojis
$latte->addFunction('render_desc', function (string $desc, array $textExtras = []): string {
$bytesCount = strlen($desc);
$charsCount = mb_strlen($desc);
// Skip urlify for now if there is a special char like an emoji to avoid issues
if ($bytesCount !== $charsCount) {
return $desc;
}
$sanitizedDesc = htmlspecialchars($desc);
$out = $sanitizedDesc;
foreach ($textExtras as $extra) {