Skip to content

Commit eaa64ef

Browse files
authored
Add height and width attributes to ballot cover images (#457)
This prevents layout shift on the ballot page. Fixes #453
1 parent 05af661 commit eaa64ef

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

IFComp/lib/IFComp/Schema/Result/Entry.pm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,15 @@ sub cover_exists {
930930
}
931931
}
932932

933+
sub cover_image {
934+
my $self = shift;
935+
936+
return 0 unless $self->cover_exists;
937+
938+
my $image = Imager->new( file => $self->web_cover_file );
939+
return $image;
940+
}
941+
933942
sub create_web_cover_file {
934943
my $self = shift;
935944

IFComp/root/src/_current_entry_row.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[% IF entry.cover_exists %]
44
<div class="col-sm-4">
55
<div itemprop="image" itemscope itemtype="https://schema.org/ImageObject">
6-
<a itemprop="contentUrl" href="[% c.uri_for_action( '/play/full_cover', [ entry.id ] ) %]" target="_blank"><img itemprop="thumbnailUrl" class="img-fluid" src="[% c.uri_for_action( '/play/cover', [ entry.id ] ) %]" alt="Cover art for [% entry.title %]" loading="lazy"></a>
6+
<a itemprop="contentUrl" href="[% c.uri_for_action( '/play/full_cover', [ entry.id ] ) %]" target="_blank"><img itemprop="thumbnailUrl" class="img-fluid" src="[% c.uri_for_action( '/play/cover', [ entry.id ] ) %]" alt="Cover art for [% entry.title %]" height="[% entry.cover_image.getheight %]" width="[% entry.cover_image.getwidth %]" loading="lazy"></a>
77
[% IF (entry.genai_state / 2) % 2 == 1 %]
88
<span style="font-size: smaller;" itemprop="genai_cover"><em>Generative artificial intelligence was used to make this cover art.</em></span>
99
[% END %]

0 commit comments

Comments
 (0)