From 1086d48051822b8f9e1e4d330794f588ee519fd5 Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 18 Jul 2024 17:05:25 +0300 Subject: [PATCH] implement image mime types support --- src/Entity/Browser/Container/Page/Content.php | 18 ++++++---- .../Browser/Container/Page/Content/Image.php | 34 +++++++++++++++++++ 2 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 src/Entity/Browser/Container/Page/Content/Image.php diff --git a/src/Entity/Browser/Container/Page/Content.php b/src/Entity/Browser/Container/Page/Content.php index b527db88..4b54cf7b 100644 --- a/src/Entity/Browser/Container/Page/Content.php +++ b/src/Entity/Browser/Container/Page/Content.php @@ -113,14 +113,20 @@ class Content break; - /* @TODO - case 'image/gif': - case 'image/jpeg': - case 'image/png': - case 'image/webp': + case Filesystem::MIME_IMAGE_GIF: + case Filesystem::MIME_IMAGE_JPEG: + case Filesystem::MIME_IMAGE_PNG: + case Filesystem::MIME_IMAGE_WEBP: + + $document = new Image( + $this + ); + + $document->set( + $data + ); break; - */ default: diff --git a/src/Entity/Browser/Container/Page/Content/Image.php b/src/Entity/Browser/Container/Page/Content/Image.php new file mode 100644 index 00000000..e95ba6c6 --- /dev/null +++ b/src/Entity/Browser/Container/Page/Content/Image.php @@ -0,0 +1,34 @@ +content = $content; + + // Init image object + $this->gtk = new \GtkImage; + } + + public function set( + string $data + ): void + { + $this->gtk->new_from_resource( + $data + ); + } +} \ No newline at end of file