mirror of
https://github.com/e107inc/e107.git
synced 2025-06-04 01:45:15 +02:00
Issue #3501 - Media-Manager icon import issue.
This commit is contained in:
parent
463b81bd2f
commit
6c2c2c7f13
@ -963,6 +963,12 @@ class e_form
|
||||
$options['glyph'] = 1;
|
||||
$options['w'] = 64;
|
||||
$options['h'] = 64;
|
||||
$options['media'] = '_icon';
|
||||
|
||||
if(!isset($options['legacyPath']))
|
||||
{
|
||||
$options['legacyPath'] = "{e_IMAGE}icons";
|
||||
}
|
||||
|
||||
return $this->mediapicker($name, $default, $options);
|
||||
|
||||
|
@ -1302,6 +1302,11 @@ class e_media
|
||||
$mes->add("Couldn't move file from ".$oldpath." to ".$newpath, E_MESSAGE_ERROR);
|
||||
return false;
|
||||
};
|
||||
|
||||
if($category === '_icon') // convert to _icon_16, _icon_32 etc.
|
||||
{
|
||||
$category = $this->getIconCategory($img_data);
|
||||
}
|
||||
|
||||
$img_data['media_url'] = $tp->createConstants($newpath,'rel');
|
||||
$img_data['media_name'] = $tp->toDB(basename($newpath));
|
||||
@ -1327,6 +1332,41 @@ class e_media
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculate Icon Category from image meta data.
|
||||
* @param array $img image meta data.
|
||||
* @return string
|
||||
*/
|
||||
private function getIconCategory($img)
|
||||
{
|
||||
|
||||
if($img['media_type'] == 'image/svg+xml')
|
||||
{
|
||||
return "_icon_svg";
|
||||
}
|
||||
|
||||
$sizes = array(16,32,48,64);
|
||||
|
||||
$dimensions = $img['media_dimensions'];
|
||||
|
||||
foreach($sizes as $dim)
|
||||
{
|
||||
list($w,$h) = explode(" x ", $dimensions);
|
||||
|
||||
if($w == $dim || $h == $dim)
|
||||
{
|
||||
return "_icon_".$dim;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return "_icon_64"; // default.
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Check File-name against mime-type and add missing extension if necessary.
|
||||
* @param $path
|
||||
|
Loading…
x
Reference in New Issue
Block a user