aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Photo.pm
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2016-05-28 13:49:00 +0200
committerMarius Halden <marius.h@lden.org>2016-05-28 13:49:00 +0200
commit6791ce86ae15adbded24bd814a78cc0e87f404fa (patch)
tree99af5da31e4db091350a09bcdee913c99abc2fc3 /perllib/FixMyStreet/App/Controller/Photo.pm
parent6c1118dbf2c4b15bcfcd77600d36f2389428c75e (diff)
parent89b0efeb94631c4c31ce33e7f98297e754dd226d (diff)
Merge tag 'v1.8.2' into fiksgatami-dev
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Photo.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Photo.pm16
1 files changed, 8 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm
index bfb1c5535..d24d3ff71 100644
--- a/perllib/FixMyStreet/App/Controller/Photo.pm
+++ b/perllib/FixMyStreet/App/Controller/Photo.pm
@@ -29,12 +29,12 @@ Display a photo
=cut
-sub during :LocalRegex('^([0-9a-f]{40})\.(temp|fulltemp)\.jpeg$') {
+sub during :LocalRegex('^(temp|fulltemp)\.([0-9a-f]{40}\.(?:jpeg|png|gif|tiff))$') {
my ( $self, $c ) = @_;
- my ( $hash, $size ) = @{ $c->req->captures };
+ my ( $size, $filename ) = @{ $c->req->captures };
my $photoset = FixMyStreet::App::Model::PhotoSet->new({
- data_items => [ $hash ]
+ data_items => [ $filename ]
});
$size = $size eq 'temp' ? 'default' : 'full';
@@ -43,7 +43,7 @@ sub during :LocalRegex('^([0-9a-f]{40})\.(temp|fulltemp)\.jpeg$') {
$c->forward( 'output', [ $photo ] );
}
-sub index :LocalRegex('^(c/)?(\d+)(?:\.(\d+))?(?:\.(full|tn|fp))?\.jpeg$') {
+sub index :LocalRegex('^(c/)?(\d+)(?:\.(\d+))?(?:\.(full|tn|fp))?\.(?:jpeg|png|gif|tiff)$') {
my ( $self, $c ) = @_;
my ( $is_update, $id, $photo_number, $size ) = @{ $c->req->captures };
@@ -79,10 +79,10 @@ sub output : Private {
# Save to file
File::Path::make_path( FixMyStreet->path_to( 'web', 'photo', 'c' )->stringify );
- File::Slurp::write_file( FixMyStreet->path_to( 'web', $c->req->path )->stringify, \$photo );
+ File::Slurp::write_file( FixMyStreet->path_to( 'web', $c->req->path )->stringify, \$photo->{data} );
- $c->res->content_type( 'image/jpeg' );
- $c->res->body( $photo );
+ $c->res->content_type( $photo->{content_type} );
+ $c->res->body( $photo->{data} );
}
sub no_photo : Private {
@@ -140,7 +140,7 @@ sub process_photo_upload_or_cache : Private {
/^photo/ ? # photo, photo1, photo2 etc.
($c->req->upload($_)) : ()
} sort $c->req->upload),
- split /,/, ($c->get_param('upload_fileid') || '')
+ grep { $_ } split /,/, ($c->get_param('upload_fileid') || '')
);
my $photoset = FixMyStreet::App::Model::PhotoSet->new({