public function getIconFilename(\ElggEntity $entity, $size = '') {

		$mimetype = $entity->icon_mimetype ? : $entity->mimetype;
		switch ($mimetype) {
			default :
				$ext = 'jpg';
				break;
			case 'image/png' :
				$ext = 'png';
				break;
			case 'image/gif' :
				$ext = 'gif';
				break;
		}

		$sizes = $this->getSizes($entity);
		if (isset($sizes[$size]['metadata_name'])) {
			$md_name = $sizes[$size]['metadata_name'];
			$filename = $entity->$md_name;
		}
		if (!$filename) {
			$filename = "{$entity->guid}{$size}.{$ext}";
		}
		return elgg_trigger_plugin_hook('entity:icon:directory', $entity->getType(), array(
			'entity' => $entity,
			'size' => $size,
				), $filename);
	}