aboutsummaryrefslogtreecommitdiff
path: root/views/default/icon/object/image.php
diff options
context:
space:
mode:
authorcash <cash.costello@gmail.com>2011-12-03 16:46:50 -0500
committercash <cash.costello@gmail.com>2011-12-03 16:46:50 -0500
commit5d26276359a4448f0aebc66c3a87b332338e7027 (patch)
treecd269deb21c9ee0211e6b7d080f9566fd2d5ecb4 /views/default/icon/object/image.php
parent092197523f135b1aec3de8ff50df0dcf724c8094 (diff)
downloadelgg-5d26276359a4448f0aebc66c3a87b332338e7027.tar.gz
elgg-5d26276359a4448f0aebc66c3a87b332338e7027.tar.bz2
better image display code - using elgg_view_entity_icon() now
Diffstat (limited to 'views/default/icon/object/image.php')
-rw-r--r--views/default/icon/object/image.php62
1 files changed, 62 insertions, 0 deletions
diff --git a/views/default/icon/object/image.php b/views/default/icon/object/image.php
new file mode 100644
index 000000000..3dbced8ab
--- /dev/null
+++ b/views/default/icon/object/image.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Image icon view
+ *
+ * @uses $vars['entity'] The entity the icon represents - uses getIconURL() method
+ * @uses $vars['size'] tiny, small (default), large, master
+ * @uses $vars['href'] Optional override for link
+ * @uses $vars['img_class'] Optional CSS class added to img
+ * @uses $vars['link_class'] Optional CSS class added to link
+ * @uses $vars['title'] Optional title override
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$entity = $vars['entity'];
+
+$sizes = array('master', 'large', 'small', 'tiny');
+// Get size
+if (!in_array($vars['size'], $sizes)) {
+ $vars['size'] = 'small';
+}
+
+if (!isset($vars['title'])) {
+ $title = $entity->getTitle();
+} else {
+ $title = $vars['title'];
+}
+
+$url = $entity->getURL();
+if (isset($vars['href'])) {
+ $url = $vars['href'];
+}
+
+$class = '';
+if (isset($vars['img_class'])) {
+ $class = $vars['img_class'];
+}
+$class = "elgg-photo $class";
+
+$img_src = $entity->getIconURL($vars['size']);
+$img_src = elgg_format_url($img_src);
+$img = elgg_view('output/img', array(
+ 'src' => $img_src,
+ 'class' => $class,
+ 'title' => $title,
+ 'alt' => $title,
+));
+
+if ($url) {
+ $params = array(
+ 'href' => $url,
+ 'text' => $img,
+ 'is_trusted' => true,
+ );
+ if (isset($vars['link_class'])) {
+ $params['class'] = $vars['link_class'];
+ }
+ echo elgg_view('output/url', $params);
+} else {
+ echo $img;
+}