diff options
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/Comment.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Comment.pm | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index 7259087be..73c5876d6 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -97,4 +97,24 @@ sub confirm { $self->state( 'confirmed' ); $self->confirmed( \'ms_current_timestamp()' ); } + +=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/?c=' . $self->id; + + return $photo; +} 1; |