diff options
author | Matthew Somerville <matthew@mysociety.org> | 2016-01-12 16:33:17 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2016-01-12 17:31:38 +0000 |
commit | df98fe4dfff0a707c9800050f658100c57783654 (patch) | |
tree | fd39aa3cf82584fbf784334da41265b5f7dbc43c | |
parent | de6df5e30d4801afc560e93c833a692a117b9547 (diff) |
Factor multiple photo details into nicer function.
Remove get_photo_params, which only looked at the first photo,
make explicit when we're doing that using `.first`.
21 files changed, 106 insertions, 202 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm index 5a5771488..df4cab2d8 100644 --- a/perllib/FixMyStreet/App/Controller/Photo.pm +++ b/perllib/FixMyStreet/App/Controller/Photo.pm @@ -4,11 +4,9 @@ use namespace::autoclean; BEGIN {extends 'Catalyst::Controller'; } -use DateTime::Format::HTTP; -use Digest::SHA qw(sha1_hex); +use JSON; use File::Path; use File::Slurp; -use Path::Class; use FixMyStreet::App::Model::PhotoSet; use if !$ENV{TRAVIS}, 'Image::Magick'; @@ -35,16 +33,12 @@ sub during :LocalRegex('^([0-9a-f]{40})\.(temp|fulltemp)\.jpeg$') { my ( $self, $c ) = @_; my ( $hash, $size ) = @{ $c->req->captures }; - my $file = file( $c->config->{UPLOAD_DIR}, "$hash.jpeg" ); - my $photo = $file->slurp; + my $photoset = FixMyStreet::App::Model::PhotoSet->new({ + data_items => [ $hash ] + }); - if ( $size eq 'temp' ) { - if ( $c->cobrand->default_photo_resize ) { - $photo = _shrink( $photo, $c->cobrand->default_photo_resize ); - } else { - $photo = _shrink( $photo, '250x250' ); - } - } + $size = $size eq 'temp' ? 'default' : 'full'; + my $photo = $photoset->get_image_data(size => $size, default => $c->cobrand->default_photo_resize); $c->forward( 'output', [ $photo ] ); } @@ -73,29 +67,9 @@ 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; - if ($item->can('get_photoset')) { - $photo = $item->get_photoset - ->get_image_data( num => $photo_number, size => $size, default => $c->cobrand->default_photo_resize ) + $photo = $item->get_photoset + ->get_image_data( num => $photo_number, size => $size, default => $c->cobrand->default_photo_resize ) 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 ] ); } @@ -116,34 +90,6 @@ sub no_photo : Private { $c->detach( '/page_error_404_not_found', [ 'No photo' ] ); } -# Shrinks a picture to the specified size, but keeping in proportion. -sub _shrink { - my ($photo, $size) = @_; - my $image = Image::Magick->new; - $image->BlobToImage($photo); - my $err = $image->Scale(geometry => "$size>"); - throw Error::Simple("resize failed: $err") if "$err"; - $image->Strip(); - my @blobs = $image->ImageToBlob(); - undef $image; - return $blobs[0]; -} - -# Shrinks a picture to 90x60, cropping so that it is exactly that. -sub _crop { - my ($photo) = @_; - my $image = Image::Magick->new; - $image->BlobToImage($photo); - my $err = $image->Resize( geometry => "90x60^" ); - throw Error::Simple("resize failed: $err") if "$err"; - $err = $image->Extent( geometry => '90x60', gravity => 'Center' ); - throw Error::Simple("resize failed: $err") if "$err"; - $image->Strip(); - my @blobs = $image->ImageToBlob(); - undef $image; - return $blobs[0]; -} - sub upload : Local { my ( $self, $c ) = @_; my @items = ( diff --git a/perllib/FixMyStreet/App/Model/PhotoSet.pm b/perllib/FixMyStreet/App/Model/PhotoSet.pm index 9abe1dce7..35a7e8a53 100644 --- a/perllib/FixMyStreet/App/Model/PhotoSet.pm +++ b/perllib/FixMyStreet/App/Model/PhotoSet.pm @@ -292,11 +292,6 @@ sub _rotate_image { } - - - -# NB: These 2 subs stolen from A::C::Photo, should be purged from there! -# # Shrinks a picture to the specified size, but keeping in proportion. sub _shrink { my ($photo, $size) = @_; diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index b7c9e9f45..ea4eda8c4 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -1172,7 +1172,7 @@ sub admin_stats { $public_response =~ s{\r?\n}{ <br/> }g if $public_response; # Assemble photo URL, if report has a photo - my $media_url = $report->get_photo_params->{url} ? ($c->cobrand->base_url . $report->get_photo_params->{url}) : ''; + my $media_url = @{$report->photos} ? ($c->cobrand->base_url . $report->photos->[0]->{url}) : ''; my @columns = ( $report->id, 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 diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 745d88629..8f9e76ad6 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -160,7 +160,6 @@ __PACKAGE__->rabx_column('geocode'); use Moo; use namespace::clean -except => [ 'meta' ]; use Utils; -use Utils::Photo; with 'FixMyStreet::Roles::Abuser', 'FixMyStreet::Roles::Extra'; @@ -483,22 +482,6 @@ sub admin_url { return $cobrand->admin_base_url . '/report_edit/' . $self->id; } -=head2 get_photo_params - -Returns a hashref of details of the attached photo, if any, for use in templates. - -NB: this method only returns the first if there are multiple photos. Use -get_photoset if you wish to access multiple photos. - -=cut - -sub get_photo_params { - # use Carp 'cluck'; - # cluck "get_photo_params called"; # TEMPORARY die to make sure I've done right thing with Zurich templates - my $self = shift; - return Utils::Photo::get_photo_params($self, 'id'); -} - =head2 is_open Returns 1 if the problem is in a open state otherwise 0. @@ -835,7 +818,7 @@ sub as_hashref { state_t => _( $self->state ), used_map => $self->used_map, is_fixed => $self->fixed_states->{ $self->state } ? 1 : 0, - photo => $self->get_photo_params, + photos => [ map { $_->{url} } @{$self->photos} ], meta => $self->confirmed ? $self->meta_line( $c ) : '', confirmed_pp => $self->confirmed ? $c->cobrand->prettify_dt( $self->confirmed ): '', created_pp => $c->cobrand->prettify_dt( $self->created ), @@ -873,6 +856,28 @@ sub get_photoset { }); } +sub photos { + my $self = shift; + 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/$id.$i.$format?$cachebust", + url_full => "/photo/$id.$i.full.$format?$cachebust", + url_tn => "/photo/$id.$i.tn.$format?$cachebust", + url_fp => "/photo/$id.$i.fp.$format?$cachebust", + idx => $i++, + } + } map { $_->[0] } $photoset->all_images; + return \@photos; +} + __PACKAGE__->has_many( "admin_log_entries", "FixMyStreet::DB::Result::AdminLog", diff --git a/perllib/Utils/Photo.pm b/perllib/Utils/Photo.pm deleted file mode 100644 index 17514f195..000000000 --- a/perllib/Utils/Photo.pm +++ /dev/null @@ -1,46 +0,0 @@ -package Utils::Photo; - -use Image::Size; - -=head2 get_photo_params - -Returns a hashref of details of any attached photo (the first, if multiple -ones) for use in templates. Hashref contains height, width and url keys. - -=cut - -sub get_photo_params { - my ($self, $key) = @_; - - return {} unless $self->photo; - - $key = ($key eq 'id') ? '' : "/$key"; - - my $pre = "/photo$key/" . $self->id; - my $post = '.jpeg'; - my $photo = {}; - - if ($self->can('get_photoset')) { - my $data = $self->get_photoset()->get_raw_image_data(0); - my $fileid = $data->[0]; - $post .= '?' . $fileid; - $photo->{url_full} = "$pre.full$post"; - } elsif (length($self->photo) == 40) { - $post .= '?' . $self->photo; - $photo->{url_full} = "$pre.full$post"; - # XXX Can't use size here because {url} (currently 250px height) may be - # being used, but at this point it doesn't yet exist to find the width - # $str = FixMyStreet->config('UPLOAD_DIR') . $self->photo . '.jpeg'; - } else { - my $str = \$self->photo; - ( $photo->{width}, $photo->{height} ) = Image::Size::imgsize( $str ); - } - - $photo->{url} = "$pre$post"; - $photo->{url_tn} = "$pre.tn$post"; - $photo->{url_fp} = "$pre.fp$post"; - - return $photo; -} - -1; diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index 6c6b4ca19..4f55a387b 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -1049,6 +1049,9 @@ subtest 'submit an update for a registered user, creating update by email' => su $mech->delete_user( $user ); }; +my $sample_file = file(__FILE__)->parent->file("sample.jpg")->stringify; +ok -e $sample_file, "sample file $sample_file exists"; + for my $test ( { desc => 'submit update for registered user', @@ -1066,6 +1069,7 @@ for my $test ( update => 'update from a registered user', add_alert => undef, fixed => undef, + photo => [ [ $sample_file, undef, Content_Type => 'image/jpeg' ], 1 ], }, changed => { update => 'Update from a registered user' @@ -1210,6 +1214,11 @@ for my $test ( $mech->content_contains("/report/" . $report_id); $mech->get_ok("/report/" . $report_id); + my $update = $report->comments->first; + ok $update, 'found update'; + + $mech->content_contains("/photo/c/" . $update->id . ".0.jpeg") if $test->{fields}->{photo}; + if ( !defined( $test->{endstate_banner} ) ) { is $mech->extract_problem_banner->{text}, undef, 'endstate banner'; } else { @@ -1223,8 +1232,6 @@ for my $test ( %{ $test->{changed} }, }; - my $update = $report->comments->first; - ok $update, 'found update'; is $update->text, $results->{update}, 'update text'; is $update->user->email, $test->{email}, 'update user'; is $update->state, 'confirmed', 'update confirmed'; diff --git a/templates/web/base/admin/report_edit.html b/templates/web/base/admin/report_edit.html index 72e2c56db..c0cdead84 100644 --- a/templates/web/base/admin/report_edit.html +++ b/templates/web/base/admin/report_edit.html @@ -79,11 +79,11 @@ class="admin-offsite-link">[% problem.latitude %], [% problem.longitude %]</a> [% IF problem.photo %] <li> <ul> - [% FOR photo IN problem.get_photoset.images %] + [% FOR photo IN problem.photos %] <li> <div class="update-img"> - <a href="[% c.cobrand.base_url %]/photo/[% photo.0 %].fulltemp.jpeg" rel="fancy"> - <img alt="Photo of this report" src="[% c.cobrand.base_url %]/photo/[% photo.0 %].temp.jpeg"> + <a href="[% c.cobrand.base_url %][% photo.url_temp_full %]" rel="fancy"> + <img alt="Photo of this report" src="[% c.cobrand.base_url %][% photo.url_temp %]"> <span>zoom</span> </a> </div> diff --git a/templates/web/base/admin/update_edit.html b/templates/web/base/admin/update_edit.html index 5ffce8bc4..54e6d52d2 100644 --- a/templates/web/base/admin/update_edit.html +++ b/templates/web/base/admin/update_edit.html @@ -51,13 +51,8 @@ <li>[% loc('Created:') %] [% PROCESS format_time time=update.created %]</li> [% IF update.photo %] -[% photo = update.get_photo_params %] -<li><img alt="Photo of this update" height="[% photo.height %]" width="[% photo.width %]" src="[% c.cobrand.base_url %] - [%~ IF update.photo.length == 40 ~%] - /photo/[% update.photo %].temp.jpeg - [%~ ELSE ~%] - [% photo.url %] - [%~ END ~%]"> +[% photo = update.photos.first %] +<li><img alt="Photo of this update" src="[% c.cobrand.base_url %][% photo.url_temp %]"> <input type="checkbox" id="remove_photo" name="remove_photo" value="1"> <label for="remove_photo" class="inline">[% loc("Remove photo (can't be undone!)") %]</label></li> [% END %] diff --git a/templates/web/base/alert/index.html b/templates/web/base/alert/index.html index 7057c83a3..4965a1103 100644 --- a/templates/web/base/alert/index.html +++ b/templates/web/base/alert/index.html @@ -39,11 +39,9 @@ within a certain distance of a particular location.', "%s is the site name"), si [% IF photos.size %] <h2>[% loc('Some photos of recent reports') %]</h2> <div class="alerts__nearby-activity__photos"> - [% FOREACH p IN photos; - photo = p.get_photo_params; - %] + [% FOREACH p IN photos %] <a href="/report/[% p.id %]"> - <img border="0" height="100" src="[% photo.url_tn %]" + <img border="0" height="100" src="[% p.photos.first.url_tn %]" alt="[% p.title | html %]" title="[% p.title | html %]"> </a> [% END %] diff --git a/templates/web/base/alert/list.html b/templates/web/base/alert/list.html index 289eb40af..385cd7d32 100644 --- a/templates/web/base/alert/list.html +++ b/templates/web/base/alert/list.html @@ -22,11 +22,9 @@ <div class="alerts__nearby-activity"> <h2>[% loc('Photos of recent nearby reports') %]</h2> <div class="alerts__nearby-activity__photos"> - [% FOREACH p IN photos; - photo = p.get_photo_params; - %] + [% FOREACH p IN photos %] <a href="/report/[% p.id %]"> - <img border="0" height="100" src="[% photo.url_tn %]" + <img border="0" height="100" src="[% p.photos.first.url_tn %]" alt="[% p.title | html %]" title="[% p.title | html %]"> </a> [% END %] diff --git a/templates/web/base/report/_item.html b/templates/web/base/report/_item.html index d79a4e9f3..6ae43f798 100644 --- a/templates/web/base/report/_item.html +++ b/templates/web/base/report/_item.html @@ -1,9 +1,7 @@ <li class="item-list__item item-list--reports__item [% item_extra_class %]"> <a href="[% c.uri_for('/report', problem.id ) %]"> - [% IF problem.photo; - photo = problem.get_photo_params - %] - <img class="img" height="60" width="90" src="[% photo.url_fp %]" alt=""> + [% IF problem.photo %] + <img class="img" height="60" width="90" src="[% problem.photos.first.url_fp %]" alt=""> [% END %] <h4>[% problem.title | html %]</h4> <small> diff --git a/templates/web/base/report/photo.html b/templates/web/base/report/photo.html index 4114fad72..9be5b6538 100644 --- a/templates/web/base/report/photo.html +++ b/templates/web/base/report/photo.html @@ -1,21 +1,9 @@ [% IF c.cobrand.allow_photo_display(object) && object.photo %] - [% IF object.can('get_photoset') %] - [% FOR photo IN object.get_photoset.images %] + [% FOR photo IN object.photos %] <div class="update-img"> - <a href="[% c.cobrand.base_url %]/photo/[% object.id %].[% loop.index %].full.jpeg?[% photo.0 %]" rel="fancy"> - <img alt="Photo of this report" src="[% c.cobrand.base_url %]/photo/[% object.id %].[% loop.index %].jpeg?[% photo.0 %]"> + <a href="[% c.cobrand.base_url %][% photo.url_full %]" rel="fancy"> + <img alt="Photo of this report" src="[% c.cobrand.base_url %][% photo.url %]"> <span>zoom</span></a> </div> [% END %] - [% ELSE %] - [%# e.g. comments %] - [% photo = object.get_photo_params %] - <div class="update-img"> - [% IF photo.url_full %]<a href="[% photo.url_full %]" rel="fancy">[% END %] - <img alt="Photo of this report" - [%- IF photo.height %]height="[% photo.height %]" width="[% photo.width %]"[% END -%] - src="[% photo.url %]"> - [%- IF photo.url_full %]<span>zoom</span></a>[% END %] - </div> - [% END %] [% END %] diff --git a/templates/web/bromley/report/_item.html b/templates/web/bromley/report/_item.html index 3bd8a8686..2540aec98 100644 --- a/templates/web/bromley/report/_item.html +++ b/templates/web/bromley/report/_item.html @@ -1,9 +1,7 @@ <li class="item-list__item item-list--reports__item item-list__item--with-pin [% c.cobrand.pin_colour(problem) %]"> <a class="[% problem.category %]" href="[% c.uri_for('/report', problem.id ) %]"> - [% IF problem.photo; - photo = problem.get_photo_params - %] - <img class="img" height="60" width="90" src="[% photo.url_fp %]" alt=""> + [% IF problem.photo %] + <img class="img" height="60" width="90" src="[% problem.photos.first.url_fp %]" alt=""> [% END %] <span>[% problem.title | html %]</span><br /> <small>[% prettify_dt( problem.confirmed, 1 ) %] diff --git a/templates/web/emptyhomes/index.html b/templates/web/emptyhomes/index.html index ca70d1d9c..1d17c3423 100644 --- a/templates/web/emptyhomes/index.html +++ b/templates/web/emptyhomes/index.html @@ -45,11 +45,9 @@ [% IF recent_photos.size %] <p id="front_photos"> - [% FOREACH p IN recent_photos; - photo = p.get_photo_params; - %] + [% FOREACH p IN recent_photos %] <a href="/report/[% p.id %]"><img border="0" height="100" - src="[% photo.url_tn %]" alt="[% p.title | html %]" title="[% p.title | html %]"></a> + src="[% p.photos.first.url_tn %]" alt="[% p.title | html %]" title="[% p.title | html %]"></a> [% END %] </p> [% END %] diff --git a/templates/web/fixmybarangay/alert/index.html b/templates/web/fixmybarangay/alert/index.html index c168fa41b..c842a7683 100644 --- a/templates/web/fixmybarangay/alert/index.html +++ b/templates/web/fixmybarangay/alert/index.html @@ -30,11 +30,9 @@ FixMyBarangay has a RSS feeds and email alerts for local problems. <div id="alert_recent"> <aside> <h2>[% loc('Some photos of recent reports') %]</h2> - [% FOREACH p IN photos; - photo = p.get_photo_params - %] + [% FOREACH p IN photos %] <a href="/report/[% p.id %]"><img border="0" height="100" - src="[% photo.url_tn %]" alt="[% p.title | html %]" title="[% p.title | html %]"></a> + src="[% p.photos.first.url_tn %]" alt="[% p.title | html %]" title="[% p.title | html %]"></a> [% END %] </aside> </div> diff --git a/templates/web/zurich/admin/problem_row.html b/templates/web/zurich/admin/problem_row.html index 8a26f28ae..acbf17017 100644 --- a/templates/web/zurich/admin/problem_row.html +++ b/templates/web/zurich/admin/problem_row.html @@ -36,9 +36,9 @@ <td> [% IF problem.photo %] - [% FOR photo IN problem.get_photoset.images %] + [% FOR photo IN problem.photos %] <div class="update-img"> - <img height="60" width="90" alt="" src="[% c.cobrand.base_url %]/photo/[% photo.0 %].temp.jpeg"> + <img height="60" width="90" alt="" src="[% c.cobrand.base_url %][% photo.url_temp %]"> </div> [% END %] [% END %] diff --git a/templates/web/zurich/admin/report_edit-sdm.html b/templates/web/zurich/admin/report_edit-sdm.html index 1d1b60e56..a0ff1038d 100644 --- a/templates/web/zurich/admin/report_edit-sdm.html +++ b/templates/web/zurich/admin/report_edit-sdm.html @@ -82,10 +82,10 @@ [% IF problem.photo %] <dd> - [% FOR photo IN problem.get_photoset.images %] + [% FOR photo IN problem.photos %] <div class="update-img"> - <a href="[% c.cobrand.base_url %]/photo/[% photo.0 %].fulltemp.jpeg" rel="fancy"> - <img alt="Photo of this report" src="[% c.cobrand.base_url %]/photo/[% photo.0 %].temp.jpeg"> + <a href="[% c.cobrand.base_url %][% photo.url_temp_full %]" rel="fancy"> + <img alt="Photo of this report" src="[% c.cobrand.base_url %][% photo.url_temp %]"> <span>zoom</span> </a> </div> diff --git a/templates/web/zurich/admin/report_edit.html b/templates/web/zurich/admin/report_edit.html index 239646f6c..dd876935c 100644 --- a/templates/web/zurich/admin/report_edit.html +++ b/templates/web/zurich/admin/report_edit.html @@ -106,10 +106,10 @@ [% IF problem.photo %] <dd> - [% FOR photo IN problem.get_photoset.images %] + [% FOR photo IN problem.photos %] <div class="update-img"> - <a href="[% c.cobrand.base_url %]/photo/[% photo.0 %].fulltemp.jpeg" rel="fancy"> - <img alt="Photo of this report" src="[% c.cobrand.base_url %]/photo/[% photo.0 %].temp.jpeg"> + <a href="[% c.cobrand.base_url %][% photo.url_temp_full %]" rel="fancy"> + <img alt="Photo of this report" src="[% c.cobrand.base_url %][% photo.url_temp %]"> <span>zoom</span> </a> </div> diff --git a/templates/web/zurich/admin/update_edit.html b/templates/web/zurich/admin/update_edit.html index ab40981a5..fbd96f3a5 100644 --- a/templates/web/zurich/admin/update_edit.html +++ b/templates/web/zurich/admin/update_edit.html @@ -29,8 +29,8 @@ <li>[% loc('Created:') %] [% PROCESS format_date this_date=update.created %] [% update.created.hms %]</li> [% IF update.photo %] -[% photo = update.get_photo_params %] -<li><img alt="" height="[% photo.height %]" width="[% photo.width %]" src="[% photo.url %]"> +[% photo = update.photos.first %] +<li><img alt="" src="[% photo.url %]"> <input type="checkbox" id="remove_photo" name="remove_photo" value="1"> <label for="remove_photo" class="inline">[% loc("Remove photo (can't be undone!)") %]</label></li> [% END %] diff --git a/templates/web/zurich/report/_item.html b/templates/web/zurich/report/_item.html index 9ba5e6fcb..a4d274a8e 100644 --- a/templates/web/zurich/report/_item.html +++ b/templates/web/zurich/report/_item.html @@ -1,9 +1,7 @@ <li class="item-list__item item-list--reports__item"> <a href="[% c.uri_for('/report', problem.id ) %]"> - [% IF problem.state != 'unconfirmed' AND problem.photo AND c.cobrand.allow_photo_display(problem); - photo = problem.get_photo_params - %] - <img class="img" height="60" width="90" src="[% photo.url_fp %]" alt=""> + [% IF problem.state != 'unconfirmed' AND problem.photo AND c.cobrand.allow_photo_display(problem) %] + <img class="img" height="60" width="90" src="[% problem.photos.first.url_fp %]" alt=""> [% END %] [% IF problem.state != 'unconfirmed' %] <h4>[% problem.title | html %]</h4> |