diff options
author | Struan Donald <struan@exo.org.uk> | 2011-05-19 14:51:04 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-05-19 14:51:04 +0100 |
commit | a74f2325b3bbf447ba7de33b0d74fffdc219114c (patch) | |
tree | d1699eea324348753a152ccb95b5b1618d822d2f /perllib/FixMyStreet/DB/Result/Problem.pm | |
parent | da4b53a953c7a46607c5907709cade12ffea6bf7 (diff) |
push photo parameter generation to the model and create photo template
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/Problem.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 57bbf5fb8..d91e8c324 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -225,4 +225,24 @@ sub url { return "/report/" . $self->id; } +=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 = shift; + + return {} unless $self->photo; + + my $photo = {}; + ( $photo->{width}, $photo->{height} ) = + Image::Size::imgsize( \$self->photo ); + $photo->{url} = '/photo/?id=' . $self->id; + + return $photo; +} + 1; |