From e5227e9221edbce84eee82af7f2c9903de702f37 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 5 Feb 2011 22:46:28 +0000 Subject: Fixes #2559 refs #2475 added ElggEntity:getIconURL() and elgg_view_entity_icon() git-svn-id: http://code.elgg.org/elgg/trunk@8039 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/classes/ElggEntity.php | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) (limited to 'engine/classes/ElggEntity.php') diff --git a/engine/classes/ElggEntity.php b/engine/classes/ElggEntity.php index 21aa72561..5e43ab582 100644 --- a/engine/classes/ElggEntity.php +++ b/engine/classes/ElggEntity.php @@ -832,19 +832,50 @@ abstract class ElggEntity extends ElggData implements return $url; } + /** + * Get the URL for this entity's icon + * + * Plugins can register for the 'entity:icon:url', plugin hook + * to customize the icon for an entity. + * + * @param string $size Size of the icon: tiny, small, medium, large + * + * @return string The URL + * @since 1.8.0 + */ + public function getIconURL($size = 'medium') { + $size = elgg_strtolower($size); + + if (isset($this->icon_override[$size])) { + elgg_deprecated_notice("icon_override on an individual entity is deprecated", 1.8); + return $this->icon_override[$size]; + } + + $url = "_graphics/icons/default/$size.png"; + $url = elgg_normalize_url($url); + + $type = $this->getType(); + $params = array( + 'entity' => $this, + 'size' => $size, + ); + + $url = elgg_trigger_plugin_hook('entity:icon:url', $type, $params, $url); + + return elgg_normalize_url($url); + } + /** * Returns a URL for the entity's icon. * * @param string $size Either 'large', 'medium', 'small' or 'tiny' * * @return string The url or false if no url could be worked out. - * @see get_entity_icon_url() + * @deprecated Use getIconURL() */ public function getIcon($size = 'medium') { - if (isset($this->icon_override[$size])) { - return $this->icon_override[$size]; - } - return get_entity_icon_url($this, $size); + elgg_deprecated_notice("getIcon() deprecated by getIconURL()", 1.8); + return $this->getIconURL($size); } /** -- cgit v1.2.3