summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2020-12-03 19:50:45 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2020-12-07 15:44:04 +0100
commit7f61535a1a51becd984289455dc3df97a8985996 (patch)
treec22537d3b825e5f1a6313f87c8cd2df0d626d7b5 /lib/private
parentbbf66f8637506d01f9bce5c80064346297521506 (diff)
downloadnextcloud-server-7f61535a1a51becd984289455dc3df97a8985996.tar.gz
nextcloud-server-7f61535a1a51becd984289455dc3df97a8985996.zip
GD images
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/legacy/OC_Image.php17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/private/legacy/OC_Image.php b/lib/private/legacy/OC_Image.php
index 3e9812c99f2..523468701c7 100644
--- a/lib/private/legacy/OC_Image.php
+++ b/lib/private/legacy/OC_Image.php
@@ -98,7 +98,14 @@ class OC_Image implements \OCP\IImage {
* @return bool
*/
public function valid() { // apparently you can't name a method 'empty'...
- return is_resource($this->resource);
+ if (is_resource($this->resource)) {
+ return true;
+ }
+ if (is_object($this->resource) && get_class($this->resource) === 'GdImage') {
+ return true;
+ }
+
+ return false;
}
/**
@@ -305,7 +312,13 @@ class OC_Image implements \OCP\IImage {
* @throws \InvalidArgumentException in case the supplied resource does not have the type "gd"
*/
public function setResource($resource) {
- if (get_resource_type($resource) === 'gd') {
+ // For PHP<8
+ if (is_resource($resource) && get_resource_type($resource) === 'gd') {
+ $this->resource = $resource;
+ return;
+ }
+ // PHP 8 has real objects for GD stuff
+ if (is_object($resource) && get_class($resource) === 'GdImage') {
$this->resource = $resource;
return;
}