fix(oembed.php): remove fallback hardcoded values; correct case where description might be empty
This commit is contained in:
parent
36fbba761a
commit
929bc9f9f8
3 changed files with 12 additions and 16 deletions
|
@ -16,11 +16,12 @@ class OembedHandler extends BaseHandler
|
|||
$relativePath = $parsed['path'] ?? null;
|
||||
|
||||
if (!$requestUrl || $relativePath === '/') $this->sendResponse($this->buildResponse(
|
||||
$globals['site_name'],
|
||||
$globals['url'],
|
||||
$globals['metadata']['open_graph_image'],
|
||||
$globals
|
||||
));
|
||||
$globals['site_name'],
|
||||
$globals['url'],
|
||||
$globals['metadata']['open_graph_image'],
|
||||
$globals,
|
||||
$globals['site_description']
|
||||
));
|
||||
|
||||
if (!$relativePath) $this->sendErrorResponse('Invalid url', 400);
|
||||
|
||||
|
@ -89,8 +90,8 @@ class OembedHandler extends BaseHandler
|
|||
'provider_name' => $globals['site_name'],
|
||||
'provider_url' => $globals['url'],
|
||||
'thumbnail_url' => $globals['url'] . '/og/w800' . $imagePath,
|
||||
'html' => $html,
|
||||
'description' => $safeDescription,
|
||||
'html' => $html ?? $globals['site_description'],
|
||||
'description' => $safeDescription ?? $globals['site_description'],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -100,12 +101,7 @@ class OembedHandler extends BaseHandler
|
|||
|
||||
if ($this->cache && $this->cache->exists($cacheKey)) return json_decode($this->cache->get($cacheKey), true);
|
||||
|
||||
$globals = $this->fetchFromApi('optimized_globals', 'limit=1')[0] ?? [
|
||||
'author' => 'Cory Dransfeldt',
|
||||
'site_name' => 'coryd.dev',
|
||||
'url' => 'https://www.coryd.dev',
|
||||
'avatar' => ''
|
||||
];
|
||||
$globals = $this->fetchFromApi('optimized_globals', 'limit=1')[0];
|
||||
|
||||
if ($this->cache) $this->cache->setex($cacheKey, 3600, json_encode($globals));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue