diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index edb26384c..8a82c20f4 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -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); diff --git a/e107_handlers/media_class.php b/e107_handlers/media_class.php index 27656ca80..59564e173 100644 --- a/e107_handlers/media_class.php +++ b/e107_handlers/media_class.php @@ -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