chore(oembed.php): add additional html/description to oembed respobse
This commit is contained in:
parent
84a1c0d4cc
commit
c29105f42d
3 changed files with 19 additions and 12 deletions
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
require __DIR__ . '/../server/utils/init.php';
|
||||
require __DIR__ . "/Classes/BaseHandler.php";
|
||||
|
||||
use App\Classes\BaseHandler;
|
||||
|
@ -31,7 +32,8 @@ class OembedHandler extends BaseHandler
|
|||
$item['title'],
|
||||
$item['url'],
|
||||
$item['image_url'],
|
||||
$globals
|
||||
$globals,
|
||||
$item['description'] ?? ''
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -49,8 +51,12 @@ class OembedHandler extends BaseHandler
|
|||
$this->sendErrorResponse('No match found', 404);
|
||||
}
|
||||
|
||||
private function buildResponse(string $title, string $url, string $imagePath, array $globals): array
|
||||
private function buildResponse(string $title, string $url, string $imagePath, array $globals, string $description = ''): array
|
||||
{
|
||||
$safeDescription = truncateText(strip_tags(parseMarkdown($description)), 175);
|
||||
$html = '<p><a href="' . htmlspecialchars($url) . '">' . htmlspecialchars($title) . '</a></p>';
|
||||
if ($description) $html .= '<p>' . htmlspecialchars($safeDescription, ENT_QUOTES, 'UTF-8') . '</p>';
|
||||
|
||||
return [
|
||||
'version' => '1.0',
|
||||
'type' => 'link',
|
||||
|
@ -59,7 +65,8 @@ class OembedHandler extends BaseHandler
|
|||
'provider_name' => $globals['site_name'],
|
||||
'provider_url' => $globals['url'],
|
||||
'thumbnail_url' => $globals['url'] . '/og/w800' . $imagePath,
|
||||
'html' => '<a href="' . htmlspecialchars($url) . '">' . htmlspecialchars($title) . '</a>',
|
||||
'html' => $html,
|
||||
'description' => $safeDescription,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue