aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Roles/PhotoSet.pm
blob: 9607b504961c0b317b2ec67418556c82504abe67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package FixMyStreet::Roles::PhotoSet;
use Moo::Role;

=head1 NAME

FixMyStreet::Roles::Photoset - role for accessing photosets

=cut

=head2 get_photoset

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_photoset {
    my ($self) = @_;
    my $class = 'FixMyStreet::App::Model::PhotoSet';
    eval "use $class";
    return $class->new({
        db_data => $self->photo,
        object => $self,
    });
}

sub get_first_image_fp {
    my ($self) = @_;
    return $self->get_photoset->get_image_data( num => 0, size => 'fp' );
}

1;