aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Utils
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2016-01-12 16:33:17 +0000
committerMatthew Somerville <matthew@mysociety.org>2016-01-12 17:31:38 +0000
commitdf98fe4dfff0a707c9800050f658100c57783654 (patch)
treefd39aa3cf82584fbf784334da41265b5f7dbc43c /perllib/Utils
parentde6df5e30d4801afc560e93c833a692a117b9547 (diff)
Factor multiple photo details into nicer function.
Remove get_photo_params, which only looked at the first photo, make explicit when we're doing that using `.first`.
Diffstat (limited to 'perllib/Utils')
-rw-r--r--perllib/Utils/Photo.pm46
1 files changed, 0 insertions, 46 deletions
diff --git a/perllib/Utils/Photo.pm b/perllib/Utils/Photo.pm
deleted file mode 100644
index 17514f195..000000000
--- a/perllib/Utils/Photo.pm
+++ /dev/null
@@ -1,46 +0,0 @@
-package Utils::Photo;
-
-use Image::Size;
-
-=head2 get_photo_params
-
-Returns a hashref of details of any attached photo (the first, if multiple
-ones) for use in templates. Hashref contains height, width and url keys.
-
-=cut
-
-sub get_photo_params {
- my ($self, $key) = @_;
-
- return {} unless $self->photo;
-
- $key = ($key eq 'id') ? '' : "/$key";
-
- my $pre = "/photo$key/" . $self->id;
- my $post = '.jpeg';
- my $photo = {};
-
- if ($self->can('get_photoset')) {
- my $data = $self->get_photoset()->get_raw_image_data(0);
- my $fileid = $data->[0];
- $post .= '?' . $fileid;
- $photo->{url_full} = "$pre.full$post";
- } elsif (length($self->photo) == 40) {
- $post .= '?' . $self->photo;
- $photo->{url_full} = "$pre.full$post";
- # XXX Can't use size here because {url} (currently 250px height) may be
- # being used, but at this point it doesn't yet exist to find the width
- # $str = FixMyStreet->config('UPLOAD_DIR') . $self->photo . '.jpeg';
- } else {
- my $str = \$self->photo;
- ( $photo->{width}, $photo->{height} ) = Image::Size::imgsize( $str );
- }
-
- $photo->{url} = "$pre$post";
- $photo->{url_tn} = "$pre.tn$post";
- $photo->{url_fp} = "$pre.fp$post";
-
- return $photo;
-}
-
-1;