diff options
Diffstat (limited to 'engine/lib/entities.php')
-rw-r--r-- | engine/lib/entities.php | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 663ac9c4e..47ad8f89c 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -43,7 +43,12 @@ /**
* If set, overrides the value of getURL()
*/
- protected $url_override;
+ protected $url_override; + + /** + * Icon override, overrides the value of getIcon(). + */ + protected $icon_override; /** * Temporary cache for metadata, permitting meta data access before a guid has obtained. @@ -498,6 +503,36 @@ } /** + * Return a url for the entity's icon, trying multiple alternatives. + * + * @param string $size Either 'large','medium','small' or 'tiny' + * @return string The url or false if no url could be worked out. + */ + public function getIcon($size = 'medium') + { + if (isset($this->icon_override[$size])) return $this->icon_override[$size]; + return elgg_get_entity_icon_url($this, $size); + } + + /** + * Set an icon override for an icon and size. + * + * @param string $url The url of the icon. + * @param string $size The size its for. + * @return bool + */ + public function setIcon($url, $size = 'medium') + { + $url = sanitise_string($url); + $size = sanitise_string($size); + + if (!$this->icon_override) $this->icon_override = array(); + $this->icon_override[$size] = $url; + + return true; + } + + /** * Tests to see whether the object has been fully loaded. * * @return bool @@ -1632,6 +1667,7 @@ } + /** * Gets the URL for an entity, given a particular GUID * |