aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2015-10-06 14:53:23 +0100
committerDave Arter <davea@mysociety.org>2015-10-06 15:01:52 +0100
commit47b851e09c581498bd3f632ee6805a2eae846da3 (patch)
tree659246dbf26df25c9c0e5a0f810f919e6ac4f0a3 /perllib/FixMyStreet/App/Controller
parent2ed2c57659c0d288cd1cec391baef9faf002030d (diff)
Fix display of comment photos
These still use the old method of storing photos, not PhotoSet, and so don't have a get_photoset method.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r--perllib/FixMyStreet/App/Controller/Photo.pm28
1 files changed, 24 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm
index 6255bb192..bc72f4bfb 100644
--- a/perllib/FixMyStreet/App/Controller/Photo.pm
+++ b/perllib/FixMyStreet/App/Controller/Photo.pm
@@ -78,10 +78,30 @@ sub index :LocalRegex('^(c/)?(\d+)(?:\.(\d+))?(?:\.(full|tn|fp))?\.jpeg$') {
$c->detach( 'no_photo' ) unless $c->cobrand->allow_photo_display($item); # Should only be for reports, not updates
- my $photo = $item->get_photoset( $c )
- ->get_image_data( num => $photo_number, size => $size )
-
- or $c->detach( 'no_photo' );
+ my $photo;
+ if ($item->can('get_photoset')) {
+ $photo = $item->get_photoset( $c )
+ ->get_image_data( num => $photo_number, size => $size )
+ or $c->detach( 'no_photo' );
+ } else {
+ $photo = $item->photo;
+ # If photo field contains a hash
+ if (length($photo) == 40) {
+ my $file = file( $c->config->{UPLOAD_DIR}, "$photo.jpeg" );
+ $photo = $file->slurp;
+ }
+
+ if ( $size eq 'tn' ) {
+ $photo = _shrink( $photo, 'x100' );
+ } elsif ( $size eq 'fp' ) {
+ $photo = _crop( $photo );
+ } elsif ( $size eq 'full' ) {
+ } elsif ( $c->cobrand->default_photo_resize ) {
+ $photo = _shrink( $photo, $c->cobrand->default_photo_resize );
+ } else {
+ $photo = _shrink( $photo, '250x250' );
+ }
+ }
$c->forward( 'output', [ $photo ] );
}