Browse Source

Allow empty mimeType

Signed-off-by: J0WI <J0WI@users.noreply.github.com>
pull/35560/head
J0WI 4 years ago
parent
commit
110ea0df46
  1. 2
      lib/private/StreamImage.php
  2. 15
      lib/private/legacy/OC_Image.php
  3. 8
      lib/public/IImage.php

2
lib/private/StreamImage.php

@ -37,7 +37,7 @@ class StreamImage implements IStreamImage {
/** @var resource The internal stream */ /** @var resource The internal stream */
private $stream; private $stream;
/** @var string */
/** @var null|string */
private $mimeType; private $mimeType;
/** @var int */ /** @var int */

15
lib/private/legacy/OC_Image.php

@ -60,7 +60,7 @@ class OC_Image implements \OCP\IImage {
protected $resource = false; // tmp resource. protected $resource = false; // tmp resource.
/** @var int */ /** @var int */
protected $imageType = IMAGETYPE_PNG; // Default to png if file type isn't evident. protected $imageType = IMAGETYPE_PNG; // Default to png if file type isn't evident.
/** @var string */
/** @var null|string */
protected $mimeType = 'image/png'; // Default to png protected $mimeType = 'image/png'; // Default to png
/** @var null|string */ /** @var null|string */
protected $filePath = null; protected $filePath = null;
@ -116,12 +116,12 @@ class OC_Image implements \OCP\IImage {
} }
/** /**
* Returns the MIME type of the image or an empty string if no image is loaded.
* Returns the MIME type of the image or null if no image is loaded.
* *
* @return string * @return string
*/ */
public function mimeType(): string {
return $this->valid() ? $this->mimeType : '';
public function mimeType(): ?string {
return $this->valid() ? $this->mimeType : null;
} }
/** /**
@ -354,12 +354,11 @@ class OC_Image implements \OCP\IImage {
} }
/** /**
* @return string Returns the mimetype of the data. Returns the empty string
* if the data is not valid.
* @return string Returns the mimetype of the data. Returns null if the data is not valid.
*/ */
public function dataMimeType(): string {
public function dataMimeType(): ?string {
if (!$this->valid()) { if (!$this->valid()) {
return '';
return null;
} }
switch ($this->mimeType) { switch ($this->mimeType) {

8
lib/public/IImage.php

@ -41,11 +41,11 @@ interface IImage {
public function valid(): bool; public function valid(): bool;
/** /**
* Returns the MIME type of the image or an empty string if no image is loaded.
* Returns the MIME type of the image or null if no image is loaded.
* *
* @since 8.1.0 * @since 8.1.0
*/ */
public function mimeType(): string;
public function mimeType(): ?string;
/** /**
* Returns the width of the image or -1 if no image is loaded. * Returns the width of the image or -1 if no image is loaded.
@ -98,11 +98,11 @@ interface IImage {
public function resource(); public function resource();
/** /**
* @return string Returns the mimetype of the data. Returns the empty string
* @return string Returns the mimetype of the data. Returns null
* if the data is not valid. * if the data is not valid.
* @since 13.0.0 * @since 13.0.0
*/ */
public function dataMimeType(): string;
public function dataMimeType(): ?string;
/** /**
* @return string Returns the raw image data. * @return string Returns the raw image data.

Loading…
Cancel
Save