mirror of
https://github.com/e107inc/e107.git
synced 2025-01-16 20:28:28 +01:00
Fixes #5387 - Avatar mime type on remote image.
This commit is contained in:
parent
6aa42ccad9
commit
b51833b794
@ -4395,10 +4395,18 @@ class e_parse
|
||||
|
||||
if (!empty($options['base64'])) // embed image data into URL.
|
||||
{
|
||||
$content = e107::getFile()->getRemoteContent($url); // returns false during unit tests, works otherwise.
|
||||
$content = e107::getFile()->getRemoteContent($url);
|
||||
if (!empty($content))
|
||||
{
|
||||
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
|
||||
if(!empty($file))
|
||||
{
|
||||
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
|
||||
}
|
||||
else
|
||||
{
|
||||
$ext = strtolower(pathinfo($url, PATHINFO_EXTENSION));
|
||||
}
|
||||
|
||||
$url = 'data:image/' . $ext . ';base64,' . base64_encode($content);
|
||||
}
|
||||
}
|
||||
|
@ -2433,16 +2433,24 @@ EXPECTED;
|
||||
'alt="mytitle"',
|
||||
)
|
||||
),
|
||||
/** @fixme - doesn't pass under CLI */
|
||||
/*
|
||||
|
||||
7 => array(
|
||||
'input' => array('user_image'=>'avatartest.png'),
|
||||
'parms' => array('w'=>50, 'h'=>50, 'crop'=>true, 'base64'=>true, 'shape'=>'circle'),
|
||||
'expected' => array(
|
||||
"src='data:image/png;base64,",
|
||||
"class='img-circle user-avatar'"
|
||||
"class='img-circle rounded-circle user-avatar'"
|
||||
)
|
||||
),*/
|
||||
),
|
||||
|
||||
8 => array(
|
||||
'input' => array('user_image'=>'https://e107.org/e107_images/generic/blank_avatar.jpg'), // Test remote avatar
|
||||
'parms' => array('w'=>50, 'h'=>50, 'crop'=>true, 'base64'=>true, 'shape'=>'circle'),
|
||||
'expected' => array(
|
||||
"src='data:image/jpg;base64,",
|
||||
"class='img-circle rounded-circle user-avatar'"
|
||||
)
|
||||
),
|
||||
|
||||
|
||||
);
|
||||
@ -2452,7 +2460,7 @@ EXPECTED;
|
||||
$result = $this->tp->toAvatar($var['input'], $var['parms']);
|
||||
foreach ($var['expected'] as $str)
|
||||
{
|
||||
$this->assertStringContainsString($str, $result, "Failed on index #" . $index);
|
||||
self::assertStringContainsString($str, $result, "Failed on index #" . $index);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user