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
|
@ -19,7 +19,8 @@ class OembedHandler extends BaseHandler
|
||||||
$globals['site_name'],
|
$globals['site_name'],
|
||||||
$globals['url'],
|
$globals['url'],
|
||||||
$globals['metadata']['open_graph_image'],
|
$globals['metadata']['open_graph_image'],
|
||||||
$globals
|
$globals,
|
||||||
|
$globals['site_description']
|
||||||
));
|
));
|
||||||
|
|
||||||
if (!$relativePath) $this->sendErrorResponse('Invalid url', 400);
|
if (!$relativePath) $this->sendErrorResponse('Invalid url', 400);
|
||||||
|
@ -89,8 +90,8 @@ class OembedHandler extends BaseHandler
|
||||||
'provider_name' => $globals['site_name'],
|
'provider_name' => $globals['site_name'],
|
||||||
'provider_url' => $globals['url'],
|
'provider_url' => $globals['url'],
|
||||||
'thumbnail_url' => $globals['url'] . '/og/w800' . $imagePath,
|
'thumbnail_url' => $globals['url'] . '/og/w800' . $imagePath,
|
||||||
'html' => $html,
|
'html' => $html ?? $globals['site_description'],
|
||||||
'description' => $safeDescription,
|
'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);
|
if ($this->cache && $this->cache->exists($cacheKey)) return json_decode($this->cache->get($cacheKey), true);
|
||||||
|
|
||||||
$globals = $this->fetchFromApi('optimized_globals', 'limit=1')[0] ?? [
|
$globals = $this->fetchFromApi('optimized_globals', 'limit=1')[0];
|
||||||
'author' => 'Cory Dransfeldt',
|
|
||||||
'site_name' => 'coryd.dev',
|
|
||||||
'url' => 'https://www.coryd.dev',
|
|
||||||
'avatar' => ''
|
|
||||||
];
|
|
||||||
|
|
||||||
if ($this->cache) $this->cache->setex($cacheKey, 3600, json_encode($globals));
|
if ($this->cache) $this->cache->setex($cacheKey, 3600, json_encode($globals));
|
||||||
|
|
||||||
|
|
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "coryd.dev",
|
"name": "coryd.dev",
|
||||||
"version": "7.0.7",
|
"version": "7.0.8",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "coryd.dev",
|
"name": "coryd.dev",
|
||||||
"version": "7.0.7",
|
"version": "7.0.8",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"minisearch": "^7.1.2",
|
"minisearch": "^7.1.2",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "coryd.dev",
|
"name": "coryd.dev",
|
||||||
"version": "7.0.7",
|
"version": "7.0.8",
|
||||||
"description": "The source for my personal site. Built using 11ty (and other tools).",
|
"description": "The source for my personal site. Built using 11ty (and other tools).",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue