mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Issue #4270 - WebP support.
This commit is contained in:
@@ -4638,7 +4638,7 @@ class e_parser
|
|||||||
$path = null;
|
$path = null;
|
||||||
$file = trim($file);
|
$file = trim($file);
|
||||||
$ext = pathinfo($file, PATHINFO_EXTENSION);
|
$ext = pathinfo($file, PATHINFO_EXTENSION);
|
||||||
$accepted = array('jpg','gif','png','jpeg', 'svg');
|
$accepted = array('jpg','gif','png','jpeg', 'svg', 'webp');
|
||||||
|
|
||||||
|
|
||||||
if(!in_array($ext,$accepted))
|
if(!in_array($ext,$accepted))
|
||||||
|
@@ -536,6 +536,7 @@ class e_thumbnail
|
|||||||
'jpg' => 'image/jpeg',
|
'jpg' => 'image/jpeg',
|
||||||
'jpeg' => 'image/jpeg',
|
'jpeg' => 'image/jpeg',
|
||||||
'png' => 'image/png',
|
'png' => 'image/png',
|
||||||
|
'webp' => 'image/webp',
|
||||||
//'bmp' => 'image/bmp',
|
//'bmp' => 'image/bmp',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -556,8 +556,9 @@ class e_file
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $address
|
* @param string $address
|
||||||
* @param array|null $options
|
* @param array|null $options
|
||||||
|
* @return CurlHandle|false|resource
|
||||||
*/
|
*/
|
||||||
function initCurl($address, $options =null)
|
function initCurl($address, $options =null)
|
||||||
{
|
{
|
||||||
@@ -1720,7 +1721,7 @@ class e_file
|
|||||||
unlink(e_TEMP.$localfile);
|
unlink(e_TEMP.$localfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->getRemoteFile($remotefile, $localfile, 'temp');
|
$result = $this->getRemoteFile($remotefile, $localfile);
|
||||||
|
|
||||||
if($result === false)
|
if($result === false)
|
||||||
{
|
{
|
||||||
@@ -2023,6 +2024,7 @@ class e_file
|
|||||||
case 'wbmp':
|
case 'wbmp':
|
||||||
case 'xbm':
|
case 'xbm':
|
||||||
case 'ico':
|
case 'ico':
|
||||||
|
case 'webp':
|
||||||
|
|
||||||
$ret = $this->getImageMime($filename);
|
$ret = $this->getImageMime($filename);
|
||||||
|
|
||||||
@@ -2061,6 +2063,7 @@ class e_file
|
|||||||
case 'mov': //media
|
case 'mov': //media
|
||||||
case 'avi': //media
|
case 'avi': //media
|
||||||
case 'xml':
|
case 'xml':
|
||||||
|
case 'webm':
|
||||||
|
|
||||||
break; // Just accept these
|
break; // Just accept these
|
||||||
|
|
||||||
@@ -2085,12 +2088,12 @@ class e_file
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* New in v2.1.9
|
* New in v2.1.9
|
||||||
* Check filename or path against filetypes.xml
|
* Check filename or path against filetypes.xml
|
||||||
* @param $file - real path to file.
|
*
|
||||||
|
* @param $file - real path to file.
|
||||||
|
* @param string $targetFile
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isAllowedType($file,$targetFile='')
|
public function isAllowedType($file,$targetFile='')
|
||||||
@@ -2153,7 +2156,8 @@ class e_file
|
|||||||
'image/iff' => array('iff'),
|
'image/iff' => array('iff'),
|
||||||
'image/vnd.wap.wbmp' => array('wbmp'),
|
'image/vnd.wap.wbmp' => array('wbmp'),
|
||||||
'image/xbm' => array('xbm'),
|
'image/xbm' => array('xbm'),
|
||||||
'image/vnd.microsoft.icon' => array('ico')
|
'image/vnd.microsoft.icon' => array('ico'),
|
||||||
|
'image/webp' => array('webp'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$ret = image_type_to_mime_type(exif_imagetype($filename));
|
$ret = image_type_to_mime_type(exif_imagetype($filename));
|
||||||
@@ -2203,7 +2207,7 @@ class e_file
|
|||||||
|
|
||||||
$xml = e107::getXml();
|
$xml = e107::getXml();
|
||||||
$xml->setOptArrayTags('class'); // class tag should be always array
|
$xml->setOptArrayTags('class'); // class tag should be always array
|
||||||
$temp_vars = $xml->loadXMLfile(e_SYSTEM."filetypes.xml", 'filetypes', false);
|
$temp_vars = $xml->loadXMLfile(e_SYSTEM."filetypes.xml", 'filetypes');
|
||||||
|
|
||||||
if ($temp_vars === false)
|
if ($temp_vars === false)
|
||||||
{
|
{
|
||||||
|
BIN
e107_plugins/gallery/images/beach.webp
Normal file
BIN
e107_plugins/gallery/images/beach.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 219 KiB |
@@ -149,6 +149,14 @@
|
|||||||
// 'c' => 'r', // crop right
|
// 'c' => 'r', // crop right
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// Test WebP format resize.
|
||||||
|
16 => array (
|
||||||
|
'src' => 'e_PLUGIN/gallery/images/beach.webp',
|
||||||
|
'aw' => 455,
|
||||||
|
'ah' => 0,
|
||||||
|
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
||||||
@@ -172,7 +180,14 @@
|
|||||||
// $actual = getimagesize($generatedImage);
|
// $actual = getimagesize($generatedImage);
|
||||||
// $expected = getimagesize($storedImage);
|
// $expected = getimagesize($storedImage);
|
||||||
|
|
||||||
|
if($status === false)
|
||||||
|
{
|
||||||
|
rename($generatedImage,codecept_output_dir()."sendImage_".time()."_index_".$index.".".$ext);
|
||||||
|
}
|
||||||
|
|
||||||
$this->assertTrue($status, "Image Index #".$index." failed the image-comparison check");
|
$this->assertTrue($status, "Image Index #".$index." failed the image-comparison check");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -210,6 +225,12 @@ class compareImages
|
|||||||
case 'image/png':
|
case 'image/png':
|
||||||
$return[] = 'png';
|
$return[] = 'png';
|
||||||
return $return;
|
return $return;
|
||||||
|
case 'image/webp':
|
||||||
|
$return[] = 'webp';
|
||||||
|
return $return;
|
||||||
|
case 'image/gif':
|
||||||
|
$return[] = 'gif';
|
||||||
|
return $return;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -219,14 +240,29 @@ class compareImages
|
|||||||
{
|
{
|
||||||
/*retuns image resource or false if its not jpg or png*/
|
/*retuns image resource or false if its not jpg or png*/
|
||||||
$mime = $this->mimeType($i);
|
$mime = $this->mimeType($i);
|
||||||
if ($mime[2] == 'jpg') {
|
|
||||||
return imagecreatefromjpeg($i);
|
switch($mime[2])
|
||||||
} else
|
{
|
||||||
if ($mime[2] == 'png') {
|
case "jpg":
|
||||||
return imagecreatefrompng($i);
|
return imagecreatefromjpeg($i);
|
||||||
} else {
|
break;
|
||||||
return false;
|
|
||||||
}
|
case "png":
|
||||||
|
return imagecreatefrompng($i);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "gif":
|
||||||
|
return imagecreatefromgif($i);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "webp":
|
||||||
|
return imagecreatefromwebp($i);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function resizeImage($source)
|
private function resizeImage($source)
|
||||||
|
Reference in New Issue
Block a user