aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Roles/PhotoSet.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-01-18 14:06:24 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-01-18 14:06:24 +0000
commitf9b2ff83e731364f9780d42bf59bb1e4c71018f0 (patch)
tree31509711f28b74945435e6d0a57a1b8c44ddb7b8 /perllib/FixMyStreet/Roles/PhotoSet.pm
parentaa1ada8de28f8af2c4ef1ea5a8f4e633d3995741 (diff)
parent4394236a96f797d31033f6760607548266b0d354 (diff)
Merge branch 'issues/commercial/988-c6-email-address-link'
Diffstat (limited to 'perllib/FixMyStreet/Roles/PhotoSet.pm')
-rw-r--r--perllib/FixMyStreet/Roles/PhotoSet.pm34
1 files changed, 34 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Roles/PhotoSet.pm b/perllib/FixMyStreet/Roles/PhotoSet.pm
index 9607b5049..2a6863cff 100644
--- a/perllib/FixMyStreet/Roles/PhotoSet.pm
+++ b/perllib/FixMyStreet/Roles/PhotoSet.pm
@@ -32,4 +32,38 @@ sub get_first_image_fp {
return $self->get_photoset->get_image_data( num => 0, size => 'fp' );
}
+sub photos {
+ my $self = shift;
+ my $photoset = $self->get_photoset;
+ my $i = 0;
+ my $id = $self->id;
+ my $typ = $self->result_source->name eq 'comment' ? 'c/' : '';
+
+ my @photos = map {
+ my $cachebust = substr($_, 0, 8);
+ # Some Varnish configurations (e.g. on mySociety infra) strip cookies from
+ # images, which means image requests will be redirected to the login page
+ # if LOGIN_REQUIRED is set. To stop this happening, Varnish should be
+ # configured to not strip cookies if the cookie_passthrough param is
+ # present, which this line ensures will be if LOGIN_REQUIRED is set.
+ my $extra = '';
+ if (FixMyStreet->config('LOGIN_REQUIRED')) {
+ $cachebust .= '&cookie_passthrough=1';
+ $extra = '?cookie_passthrough=1';
+ }
+ my ($hash, $format) = split /\./, $_;
+ {
+ id => $hash,
+ url_temp => "/photo/temp.$hash.$format$extra",
+ url_temp_full => "/photo/fulltemp.$hash.$format$extra",
+ url => "/photo/$typ$id.$i.$format?$cachebust",
+ url_full => "/photo/$typ$id.$i.full.$format?$cachebust",
+ url_tn => "/photo/$typ$id.$i.tn.$format?$cachebust",
+ url_fp => "/photo/$typ$id.$i.fp.$format?$cachebust",
+ idx => $i++,
+ }
+ } $photoset->all_ids;
+ return \@photos;
+}
+
1;