diff options
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/Comment.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Comment.pm | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index 41e8cf315..3ae56591f 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -97,7 +97,6 @@ __PACKAGE__->load_components("+FixMyStreet::DB::RABXColumn"); __PACKAGE__->rabx_column('extra'); use Moo; -use Utils::Photo; use namespace::clean -except => [ 'meta' ]; with 'FixMyStreet::Roles::Abuser'; @@ -148,15 +147,44 @@ sub confirm { $self->confirmed( \'current_timestamp' ); } -=head2 get_photo_params +=head2 get_photoset -Returns a hashref of details of any attached photo for use in templates. +Return a PhotoSet object for all photos attached to this field + + my $photoset = $obj->get_photoset; + print $photoset->num_images; + return $photoset->get_image_data(num => 0, size => 'full'); =cut -sub get_photo_params { +sub get_photoset { + my ($self) = @_; + my $class = 'FixMyStreet::App::Model::PhotoSet'; + eval "use $class"; + return $class->new({ + db_data => $self->photo, + object => $self, + }); +} + +sub photos { my $self = shift; - return Utils::Photo::get_photo_params($self, 'c'); + my $photoset = $self->get_photoset; + my $i = 0; + my $id = $self->id; + my @photos = map { + my $format = 'jpeg'; + my $cachebust = substr($_, 0, 8); + { + id => $_, + url_temp => "/photo/$_.temp.$format", + url_temp_full => "/photo/$_.fulltemp.$format", + url => "/photo/c/$id.$i.$format?$cachebust", + url_full => "/photo/c/$id.$i.full.$format?$cachebust", + idx => $i++, + } + } map { $_->[0] } $photoset->all_images; + return \@photos; } =head2 meta_problem_state |