From 5d26276359a4448f0aebc66c3a87b332338e7027 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 3 Dec 2011 16:46:50 -0500 Subject: better image display code - using elgg_view_entity_icon() now --- classes/TidypicsAlbum.php | 16 ------ classes/TidypicsImage.php | 5 +- views/default/forms/photos/batch/edit/image.php | 6 +-- views/default/icon/object/album.php | 40 ++++++++++++++ views/default/icon/object/image.php | 62 ++++++++++++++++++++++ views/default/object/album/gallery.php | 15 ++---- views/default/object/album/list.php | 12 +---- views/default/object/image/full.php | 16 ++---- views/default/object/image/summary.php | 6 +-- views/default/river/object/album/create.php | 12 ++--- views/default/river/object/image/create.php | 9 ++-- .../default/river/object/tidypics_batch/create.php | 8 +-- views/default/tidypics/css.php | 17 +++++- views/default/widgets/album_view/content.php | 3 ++ views/default/widgets/album_view/edit.php | 3 ++ views/default/widgets/latest_photos/content.php | 3 ++ views/default/widgets/latest_photos/edit.php | 3 ++ views/rss/object/image.php | 4 +- 18 files changed, 161 insertions(+), 79 deletions(-) create mode 100644 views/default/icon/object/album.php create mode 100644 views/default/icon/object/image.php diff --git a/classes/TidypicsAlbum.php b/classes/TidypicsAlbum.php index 028811e55..e5a8e2c0c 100644 --- a/classes/TidypicsAlbum.php +++ b/classes/TidypicsAlbum.php @@ -126,22 +126,6 @@ class TidypicsAlbum extends ElggObject { return get_entity($this->getCoverImageGuid()); } - /** - * 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 * 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 '
'; echo '
'; -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 '
'; echo '
'; 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 @@ +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 @@ +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 .= '
' . 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 '
'; echo elgg_view('tidypics/tagging/help'); echo elgg_view('tidypics/tagging/select', array('photo' => $photo)); -echo $content; +echo $img; echo '
'; - 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 @@ 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 = '
    '; foreach($images as $image) { $attachments .= '
  • '; - $attachments .= elgg_view('output/img', array( - 'src' => $image->getSrcUrl('thumb'), - 'class' => 'elgg-photo', - )); + $attachments .= elgg_view_entity_icon($image, 'tiny'); $attachments .= '
  • '; } $attachments .= '
'; 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 @@ 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 @@ getObjectEntity(); @@ -34,10 +37,7 @@ if (count($images)) { $attachments = '
    '; foreach($images as $image) { $attachments .= '
  • '; - $attachments .= elgg_view('output/img', array( - 'src' => $image->getSrcUrl('thumb'), - 'class' => 'elgg-photo', - )); + $attachments .= elgg_view_entity_icon($image, 'tiny'); $attachments .= '
  • '; } $attachments .= '
'; 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; +} 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(); -- cgit v1.2.3