This commit is contained in:
grandeljay 2022-10-09 15:19:06 +02:00
parent 6689a06e37
commit b8b2d60275

View file

@ -38,8 +38,6 @@ class Embed extends Cache
$info = $this->exists() ? json_decode(file_get_contents($filepath)) : new \stdClass(); $info = $this->exists() ? json_decode(file_get_contents($filepath)) : new \stdClass();
if (true === $generateCache) { if (true === $generateCache) {
$infoToSave = $info;
try { try {
/** /**
* Fetch embed info * Fetch embed info
@ -47,31 +45,28 @@ class Embed extends Cache
* @link https://github.com/oscarotero/Embed * @link https://github.com/oscarotero/Embed
*/ */
$embed = new \Embed\Embed(); $embed = new \Embed\Embed();
$info = $embed->get($this->url); $embedInfo = $embed->get($this->url);
/** Convert embed info to a saveable format (JSON) stdClass */ /** Convert embed info to a saveable format (JSON) stdClass */
$infoToSave = new \stdClass(); $info->authorName = (string) $embedInfo->authorName;
$infoToSave->authorName = (string) $info->authorName; $info->authorUrl = (string) $embedInfo->authorUrl;
$infoToSave->authorUrl = (string) $info->authorUrl; $info->cms = (string) $embedInfo->cms;
$infoToSave->cms = (string) $info->cms; $info->code = (string) $embedInfo->code;
$infoToSave->code = (string) $info->code; $info->description = (string) $embedInfo->description;
$infoToSave->description = (string) $info->description; $info->favicon = (string) $embedInfo->favicon;
$infoToSave->favicon = (string) $info->favicon; $info->feeds = (array) $embedInfo->feeds;
$infoToSave->feeds = (array) $info->feeds; $info->icon = (string) $embedInfo->icon;
$infoToSave->icon = (string) $info->icon; $info->image = (string) $embedInfo->image;
$infoToSave->image = (string) $info->image; $info->keywords = (array) $embedInfo->keywords;
$infoToSave->keywords = (array) $info->keywords; $info->language = (string) $embedInfo->language;
$infoToSave->language = (string) $info->language; $info->languages = (array) $embedInfo->languages;
$infoToSave->languages = (array) $info->languages; $info->license = (string) $embedInfo->license;
$infoToSave->license = (string) $info->license; $info->providerName = (string) $embedInfo->providerName;
$infoToSave->providerName = (string) $info->providerName; $info->providerUrl = (string) $embedInfo->providerUrl;
$infoToSave->providerUrl = (string) $info->providerUrl; $info->publishedTime = $embedInfo->publishedTime ? $embedInfo->publishedTime->format('d.m.Y') : '';
$infoToSave->publishedTime = $info->publishedTime ? $info->publishedTime->format('d.m.Y') : ''; $info->redirect = (string) $embedInfo->redirect;
$infoToSave->redirect = (string) $info->redirect; $info->title = (string) $embedInfo->title;
$infoToSave->title = (string) $info->title; $info->url = (string) $embedInfo->url;
$infoToSave->url = (string) $info->url;
$info = $infoToSave;
} catch (\Throwable $ex) { } catch (\Throwable $ex) {
$generateCache = false; $generateCache = false;