diff options
author | Matthew Somerville <matthew@mysociety.org> | 2012-03-08 14:05:01 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2012-03-08 14:05:01 +0000 |
commit | 1a5baa677635b0fb981bd4cf83e1843f8d5ef8ab (patch) | |
tree | f86ee8c99fd6269b925640dc2bb3ebb44ee279ce /perllib/FixMyStreet/App.pm | |
parent | 410d1f1edc737d1d60e83f90053fe028eff3de30 (diff) |
Store full size photos that are uploaded on filesystem, put hash in database. Fixes #9, basics for #209 (needs light box adding).
Diffstat (limited to 'perllib/FixMyStreet/App.pm')
-rw-r--r-- | perllib/FixMyStreet/App.pm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm index 0582d88c9..262379b79 100644 --- a/perllib/FixMyStreet/App.pm +++ b/perllib/FixMyStreet/App.pm @@ -11,6 +11,7 @@ use mySociety::EmailUtil; use mySociety::Random qw(random_bytes); use FixMyStreet::Map; +use Path::Class; use URI; use URI::QueryParam; @@ -415,6 +416,30 @@ sub render_fragment { $c->view('Web')->render($c, $template, $vars); } +=head2 get_photo_params + +Returns a hashref of details of any attached photo for use in templates. +Hashref contains height, width and url keys. + +=cut + +sub get_photo_params { + my ($self, $key) = @_; + $key = ($key eq 'id') ? '' : "/$key"; + + return {} unless $self->photo; + + my $photo = {}; + if (length($self->photo) == 40) { + $photo->{url_full} = '/photo' . $key . '/' . $self->id . '.full.jpeg'; + } else { + ( $photo->{width}, $photo->{height} ) = + Image::Size::imgsize( \$self->photo ); + } + $photo->{url} = '/photo' . $key . '/' . $self->id . '.jpeg'; + + return $photo; +} =head1 SEE ALSO |