diff --git a/src/assets/img/link-previews/default.png b/src/assets/img/link-previews/default.png new file mode 100644 index 00000000..03d7d3a3 Binary files /dev/null and b/src/assets/img/link-previews/default.png differ diff --git a/src/assets/img/link-preview.svg b/src/assets/img/link-previews/default.svg similarity index 98% rename from src/assets/img/link-preview.svg rename to src/assets/img/link-previews/default.svg index c49648eb..ec338064 100644 --- a/src/assets/img/link-preview.svg +++ b/src/assets/img/link-previews/default.svg @@ -8,8 +8,8 @@ version="1.1" id="svg5" inkscape:version="1.1.2 (0a00cf5339, 2022-02-04, custom)" - sodipodi:docname="link-preview.svg" - inkscape:export-filename="C:\laragon\www\wishthis\src\assets\img\logo-square-white-background.png" + sodipodi:docname="default.svg" + inkscape:export-filename="C:\laragon\www\wishthis\src\assets\img\link-preview.png" inkscape:export-xdpi="96" inkscape:export-ydpi="96" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" @@ -27,7 +27,7 @@ inkscape:document-units="mm" showgrid="false" inkscape:zoom="0.27496367" - inkscape:cx="141.83692" + inkscape:cx="74.555304" inkscape:cy="1087.4164" inkscape:window-width="1920" inkscape:window-height="1027" diff --git a/src/classes/page.php b/src/classes/page.php index 88b9e362..b598997e 100644 --- a/src/classes/page.php +++ b/src/classes/page.php @@ -111,8 +111,9 @@ class Page */ public function __construct(string $filepath, public string $title = 'wishthis', public int $power = 0) { - $this->name = pathinfo($filepath, PATHINFO_FILENAME); - $this->description = __('wishthis is a simple, intuitive and modern wishlist platform to create, manage and view your wishes for any kind of occasion.'); + $this->name = pathinfo($filepath, PATHINFO_FILENAME); + $this->description = __('wishthis is a simple, intuitive and modern wishlist platform to create, manage and view your wishes for any kind of occasion.'); + $this->link_preview = 'https://' . $_SERVER['HTTP_HOST'] . '/src/assets/img/link-previews/default.png'; /** * Session @@ -191,6 +192,16 @@ class Page __('Development environment') ); } + + /** + * Link preview + */ + $screenshot_filepath = ROOT . '/src/assets/img/screenshots/' . $this->name . '.png'; + $screenshot_url = 'https://' . $_SERVER['HTTP_HOST'] . '/src/assets/img/screenshots/' . $this->name . '.png'; + + if (file_exists($screenshot)) { + $this->link_preview = $screenshot_url; + } } public function header(): void