aboutsummaryrefslogtreecommitdiff
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
parent092197523f135b1aec3de8ff50df0dcf724c8094 (diff)
downloadelgg-5d26276359a4448f0aebc66c3a87b332338e7027.tar.gz
elgg-5d26276359a4448f0aebc66c3a87b332338e7027.tar.bz2
better image display code - using elgg_view_entity_icon() now
-rw-r--r--classes/TidypicsAlbum.php16
-rw-r--r--classes/TidypicsImage.php5
-rw-r--r--views/default/forms/photos/batch/edit/image.php6
-rw-r--r--views/default/icon/object/album.php40
-rw-r--r--views/default/icon/object/image.php62
-rw-r--r--views/default/object/album/gallery.php15
-rw-r--r--views/default/object/album/list.php12
-rw-r--r--views/default/object/image/full.php16
-rw-r--r--views/default/object/image/summary.php6
-rw-r--r--views/default/river/object/album/create.php12
-rw-r--r--views/default/river/object/image/create.php9
-rw-r--r--views/default/river/object/tidypics_batch/create.php8
-rw-r--r--views/default/tidypics/css.php17
-rw-r--r--views/default/widgets/album_view/content.php3
-rw-r--r--views/default/widgets/album_view/edit.php3
-rw-r--r--views/default/widgets/latest_photos/content.php3
-rw-r--r--views/default/widgets/latest_photos/edit.php3
-rw-r--r--views/rss/object/image.php4
18 files changed, 161 insertions, 79 deletions
diff --git a/classes/TidypicsAlbum.php b/classes/TidypicsAlbum.php
index 028811e55..e5a8e2c0c 100644
--- a/classes/TidypicsAlbum.php
+++ b/classes/TidypicsAlbum.php
@@ -127,22 +127,6 @@ class TidypicsAlbum extends ElggObject {
}
/**
- * Get the URL for the album cover image
- *
- * @param string $size
- * @return string
- */
- public function getCoverImageURL($size = 'small') {
- $coverGuid = $this->getCoverImageGuid();
- if ($coverGuid) {
- $url = "pg/photos/thumbnail/$coverGuid/$size/";
- } else {
- $url = "mod/tidypics/graphics/empty_album.png";
- }
- return elgg_normalize_url($url);
- }
-
- /**
* Get the GUID of the album cover
*
* @return int
diff --git a/classes/TidypicsImage.php b/classes/TidypicsImage.php
index a37e0dc38..1f6812760 100644
--- a/classes/TidypicsImage.php
+++ b/classes/TidypicsImage.php
@@ -67,7 +67,10 @@ class TidypicsImage extends ElggFile {
*
* @return string
*/
- public function getSrcUrl($size = 'small') {
+ public function getIconURL($size = 'small') {
+ if ($size == 'tiny') {
+ $size = 'thumb';
+ }
return elgg_normalize_url("photos/thumbnail/$this->guid/$size/");
}
diff --git a/views/default/forms/photos/batch/edit/image.php b/views/default/forms/photos/batch/edit/image.php
index bf982ed84..eed804e90 100644
--- a/views/default/forms/photos/batch/edit/image.php
+++ b/views/default/forms/photos/batch/edit/image.php
@@ -13,11 +13,7 @@ $image = $vars['entity'];
echo '<div class="elgg-image-block">';
echo '<div class="elgg-image">';
-echo elgg_view('output/img', array(
- 'src' => $image->getSrcURL(),
- 'alt' => $image->getTitle(),
- 'class' => 'elgg-photo',
-));
+echo elgg_view_entity_icon($image, 'small', array('href' => false));
echo '</div>';
echo '<div class="elgg-body"><fieldset class="mlm">';
diff --git a/views/default/icon/object/album.php b/views/default/icon/object/album.php
new file mode 100644
index 000000000..656b2e0df
--- /dev/null
+++ b/views/default/icon/object/album.php
@@ -0,0 +1,40 @@
+<?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
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$album = $vars['entity'];
+
+$cover_guid = $album->getCoverImageGuid();
+if ($cover_guid) {
+ $vars['title'] = $album->getTitle();
+ echo elgg_view_entity_icon(get_entity($cover_guid), $vars['size'], $vars);
+} else {
+ $url = "mod/tidypics/graphics/empty_album.png";
+ $url = elgg_normalize_url($url);
+ $img = elgg_view('output/img', array(
+ 'src' => $url,
+ 'class' => 'elgg-photo',
+ 'title' => $album->getTitle(),
+ 'alt' => $album->getTitle(),
+ ));
+
+ $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);
+}
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;
+}
diff --git a/views/default/object/album/gallery.php b/views/default/object/album/gallery.php
index ee22f0436..53194b53c 100644
--- a/views/default/object/album/gallery.php
+++ b/views/default/object/album/gallery.php
@@ -10,22 +10,13 @@
$album = elgg_extract('entity', $vars);
-$album_cover = elgg_view('output/img', array(
- 'src' => $album->getCoverImageURL(),
- 'alt' => $album->getTitle(),
- 'class' => 'elgg-photo',
-));
+$album_cover = elgg_view_entity_icon($album, 'small');
$header = elgg_view('output/url', array(
'text' => $album->getTitle(),
'href' => $album->getURL(),
-));
-
-$body = elgg_view('output/url', array(
- 'text' => $album_cover,
- 'href' => $album->getURL(),
- 'encode_text' => false,
'is_trusted' => true,
+ 'class' => 'tidypics-heading',
));
$footer = elgg_view('output/url', array(
@@ -38,4 +29,4 @@ $footer .= '<div class="elgg-subtext">' . elgg_echo('album:num', array($album->g
$params = array(
'footer' => $footer,
);
-echo elgg_view_module('tidypics-album', $header, $body, $params);
+echo elgg_view_module('tidypics-album', $header, $album_cover, $params);
diff --git a/views/default/object/album/list.php b/views/default/object/album/list.php
index ccbd01cd1..e576c92f1 100644
--- a/views/default/object/album/list.php
+++ b/views/default/object/album/list.php
@@ -37,16 +37,6 @@ $params = array(
$params = $params + $vars;
$summary = elgg_view('object/elements/summary', $params);
-$cover = elgg_view('output/img', array(
- 'src' => $album->getCoverImageURL('thumb'),
- 'alt' => $album->getTitle(),
- 'class' => 'elgg-photo',
-));
-$icon = elgg_view('output/url', array(
- 'text' => $cover,
- 'href' => $album->getURL(),
- 'encode_text' => false,
- 'is_trusted' => true,
-));
+$icon = elgg_view_entity_icon($album, 'tiny');
echo $header = elgg_view_image_block($icon, $summary);
diff --git a/views/default/object/image/full.php b/views/default/object/image/full.php
index d08c03f9c..f866e432d 100644
--- a/views/default/object/image/full.php
+++ b/views/default/object/image/full.php
@@ -10,15 +10,9 @@
$image = $photo = $vars['entity'];
-$img = elgg_view('output/img', array(
- 'src' => $image->getSrcURL('large'),
- 'alt' => $image->getTitle(),
- 'class' => 'elgg-photo',
-));
-
-$content = elgg_view('output/url', array(
- 'text' => $img,
- 'href' => $image->getURL(),
+$img = elgg_view_entity_icon($image, 'large', array(
+ 'href' => false,
+ 'img_class' => 'tidypics-photo',
));
$owner_link = elgg_view('output/url', array(
@@ -62,7 +56,7 @@ if ($photo->description) {
echo '<div class="tidypics-wrapper-photo">';
echo elgg_view('tidypics/tagging/help');
echo elgg_view('tidypics/tagging/select', array('photo' => $photo));
-echo $content;
+echo $img;
echo '</div>';
- echo elgg_view_comments($photo); \ No newline at end of file
+echo elgg_view_comments($photo);
diff --git a/views/default/object/image/summary.php b/views/default/object/image/summary.php
index 71c1be6b9..16c197098 100644
--- a/views/default/object/image/summary.php
+++ b/views/default/object/image/summary.php
@@ -10,11 +10,7 @@
$image = elgg_extract('entity', $vars);
-$img = elgg_view('output/img', array(
- 'src' => $image->getSrcURL(),
- 'alt' => $image->getTitle(),
- 'class' => 'elgg-photo',
-));
+$img = elgg_view_entity_icon($image, 'small');
$header = elgg_view('output/url', array(
'text' => $image->getTitle(),
diff --git a/views/default/river/object/album/create.php b/views/default/river/object/album/create.php
index 3f9c42d7a..c8c79f406 100644
--- a/views/default/river/object/album/create.php
+++ b/views/default/river/object/album/create.php
@@ -1,6 +1,9 @@
<?php
/**
* Album river view
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
*/
$album = $vars['item']->getObjectEntity();
@@ -9,9 +12,7 @@ $album_river_view = elgg_get_plugin_setting('album_river_view', 'tidypics');
if ($album_river_view == "cover") {
$image = $album->getCoverImage();
if ($image) {
- $attachments = elgg_view('output/img', array(
- 'src' => $image->getSrcUrl('thumb'),
- ));
+ $attachments = elgg_view_entity_icon($image, 'tiny');
}
} else {
$images = $album->getImages(7);
@@ -20,10 +21,7 @@ if ($album_river_view == "cover") {
$attachments = '<ul class="tidypics-river-list">';
foreach($images as $image) {
$attachments .= '<li class="tidypics-photo-item">';
- $attachments .= elgg_view('output/img', array(
- 'src' => $image->getSrcUrl('thumb'),
- 'class' => 'elgg-photo',
- ));
+ $attachments .= elgg_view_entity_icon($image, 'tiny');
$attachments .= '</li>';
}
$attachments .= '</ul>';
diff --git a/views/default/river/object/image/create.php b/views/default/river/object/image/create.php
index 44efa0c59..08cfdc550 100644
--- a/views/default/river/object/image/create.php
+++ b/views/default/river/object/image/create.php
@@ -1,6 +1,9 @@
<?php
/**
* Image album view
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
*/
$subject = $vars['item']->getSubjectEntity();
@@ -12,10 +15,8 @@ $subject_link = elgg_view('output/url', array(
));
$image = $vars['item']->getObjectEntity();
-$attachments = elgg_view('output/img', array(
- 'src' => $image->getSrcUrl('thumb'),
- 'class' => 'elgg-photo',
-));
+$attachments = elgg_view_entity_icon($image, 'tiny');
+
$image_link = elgg_view('output/url', array(
'href' => $image->getURL(),
'text' => $image->getTitle(),
diff --git a/views/default/river/object/tidypics_batch/create.php b/views/default/river/object/tidypics_batch/create.php
index 1dfce6925..44c40c110 100644
--- a/views/default/river/object/tidypics_batch/create.php
+++ b/views/default/river/object/tidypics_batch/create.php
@@ -1,6 +1,9 @@
<?php
/**
* Batch river view
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
*/
$batch = $vars['item']->getObjectEntity();
@@ -34,10 +37,7 @@ if (count($images)) {
$attachments = '<ul class="tidypics-river-list">';
foreach($images as $image) {
$attachments .= '<li class="tidypics-photo-item">';
- $attachments .= elgg_view('output/img', array(
- 'src' => $image->getSrcUrl('thumb'),
- 'class' => 'elgg-photo',
- ));
+ $attachments .= elgg_view_entity_icon($image, 'tiny');
$attachments .= '</li>';
}
$attachments .= '</ul>';
diff --git a/views/default/tidypics/css.php b/views/default/tidypics/css.php
index b95e24193..0c0f33c2c 100644
--- a/views/default/tidypics/css.php
+++ b/views/default/tidypics/css.php
@@ -8,15 +8,27 @@
.elgg-module-tidypics-image {
width: 161px;
text-align: center;
- margin: 5px 10px;
+ margin: 5px 0;
}
.elgg-module-tidypics-image {
margin: 5px auto;
}
+
.tidypics-gallery-widget > li {
width: 100%;
}
+.tidypics-photo {
+ margin: 0 auto;
+}
+
+.tidypics-heading {
+ color: #0054A7;
+}
+.tidypics-heading:hover {
+ color: #0054A7;
+ text-decoration: none;
+}
.tidypics-input-thin {
width: 120px;
@@ -35,6 +47,9 @@
margin-left: 7px;
}
+.tidypics-gallery > li {
+ padding: 0 10px;
+}
<?php
return true;
diff --git a/views/default/widgets/album_view/content.php b/views/default/widgets/album_view/content.php
index d6476f075..88c8837b3 100644
--- a/views/default/widgets/album_view/content.php
+++ b/views/default/widgets/album_view/content.php
@@ -1,6 +1,9 @@
<?php
/**
+ * List albums in a widget
*
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
*/
$options = array(
diff --git a/views/default/widgets/album_view/edit.php b/views/default/widgets/album_view/edit.php
index fde8b87b0..873fcc3eb 100644
--- a/views/default/widgets/album_view/edit.php
+++ b/views/default/widgets/album_view/edit.php
@@ -1,6 +1,9 @@
<?php
/**
* Widget settings for newest albums
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
*/
// set default value
diff --git a/views/default/widgets/latest_photos/content.php b/views/default/widgets/latest_photos/content.php
index ecd72aec4..8a3bb4891 100644
--- a/views/default/widgets/latest_photos/content.php
+++ b/views/default/widgets/latest_photos/content.php
@@ -1,6 +1,9 @@
<?php
/**
* Display the latest photos uploaded by an individual
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
*/
echo elgg_list_entities(array(
diff --git a/views/default/widgets/latest_photos/edit.php b/views/default/widgets/latest_photos/edit.php
index ac870c9f8..dd32e2b6d 100644
--- a/views/default/widgets/latest_photos/edit.php
+++ b/views/default/widgets/latest_photos/edit.php
@@ -1,6 +1,9 @@
<?php
/**
* Widget settings for latest photos
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
*/
// set default value
diff --git a/views/rss/object/image.php b/views/rss/object/image.php
index a59021bd1..e3b67ee74 100644
--- a/views/rss/object/image.php
+++ b/views/rss/object/image.php
@@ -18,8 +18,8 @@ $creator = elgg_view('page/components/creator', $vars);
$georss = elgg_view('page/components/georss', $vars);
$extension = elgg_view('extensions/item', $vars);
-$thumbnail_url = $vars['entity']->getSrcUrl('thumb');
-$download_url = $vars['entity']->getSrcUrl('large');
+$thumbnail_url = $vars['entity']->getIconURL('tiny');
+$download_url = $vars['entity']->getIconURL('large');
$mime_type = $vars['entity']->getMimeType();