function icon($extension, $x = 0, $y = 0) { $keep_original = $x == 0 && $y == 0; // This method is not necessarely called through an instance $class = isset($this) ? $this->classname : 'Image'; $format = call_user_func(array($class, 'get_icon_default_format')); if (!$keep_original && class_exists($class)) { $icon_format = $format; $class = 'Image'; if (call_user_func(array($class, 'is_supported'), 'svg')) { $format = 'svg'; } elseif (call_user_func(array($class, 'is_supported'), 'png')) { $format = 'png'; } else { return false; } } $name = "lib/images/icons/{$extension}.{$format}"; if (!file_exists($name)) { $name = "lib/images/icons/unknown.{$format}"; } if (!$keep_original) { $icon = new $class($name, true); if ($format != $icon_format) { $icon->convert($icon_format); } $icon->resize($x, $y); return $icon->display(); } else { return ImageAbstract::get_from_file($name); } }