Description
Hello,
I think I found a bug in magento enterprise (prob community too) 1.13 and 1.14 too.
The issue is still in magento 2 since the function has not been rework.
https://github.com/magento/magento2/blob/master/lib/internal/Magento/Framework/Image/Adapter/AbstractAdapter.php#L296
This function assign for an image the heigth, width and the mime type and return the mime type as a string.
If it is call another time it should just return the mime type.
Code atm:
public function getMimeType()
{
if ($this->_fileType) {
return $this->_fileType;
} else {
list($this->_imageSrcWidth, $this->_imageSrcHeight, $this->_fileType, ) = getimagesize($this->_fileName);
$this->_fileMimeType = image_type_to_mime_type($this->_fileType);
return $this->_fileMimeType;
}
}
What's wrong with this code ?
list($this->_imageSrcWidth, $this->_imageSrcHeight, $this->_fileType, ) = getimagesize($this->_fileName);
This will set into $this->_fileType
a constant like explains here: http://php.net/manual/fr/image.constants.php
So basically an integer.
Then you use image_type_to_mime_type
which will convert the integer into a string like "image/jpeg"
Finally, you return the string, which is the right behaviour when you call a getMimeType()
.
But if you call it another time you will return $this->_fileType
which is an integer ...
So basically, you will probably have into your header something like this Content-Type: 2 instead of Content-Type: "image/jpeg"
You should replace:
if ($this->_fileType) {
return $this->_fileType;
}
by
if ($this->_fileMimeType) {
return $this->_fileMimeType;
}
I'll make a PR if you can confirm that it is really an issue.
Best regards.