Skip to content

MBS-13613: Show secondary art if no poster is available#3731

Open
IvanPisquiy06 wants to merge 3 commits intometabrainz:masterfrom
IvanPisquiy06:mbs-13613-fallback-art
Open

MBS-13613: Show secondary art if no poster is available#3731
IvanPisquiy06 wants to merge 3 commits intometabrainz:masterfrom
IvanPisquiy06:mbs-13613-fallback-art

Conversation

@IvanPisquiy06
Copy link

@IvanPisquiy06 IvanPisquiy06 commented Feb 24, 2026

Problem

Fixes MBS-13613.

Currently, when an event lacks a Front artwork (Poster), the sidebar displays a generic "No poster available" placeholder, even if there are Flyer or Banner images associated with the event.

Solution

Implemented a fallback logic natively in the database query to display a Flyer (priority 1) or a Banner (priority 2) when the Front image is missing.

  • Modified Data::Role::Art::find_by_entity to dynamically update $extra_conditions and the ORDER BY clause when querying for an event entity with $opts{is_front}.
  • The SQL query now efficiently filters for Front (Poster), Flyer, or Banner using ANY(types) and sorts the results by priority (ORDER BY is_front DESC, 'Flyer' = ANY(...) DESC, 'Banner' = ANY(...) DESC, ordering).
  • This allows the database to handle the fallback logic and return the correct prioritized image in a single query, keeping MusicBrainz::Server::Controller::Event clean.

Testing

Tested locally on event pages by injecting mock event art records via SQL to verify the new ORDER BY logic:

  • Inserted a Flyer and Banner without a Front -> Verified Flyer is displayed.
  • Inserted only a Banner -> Verified Banner is displayed.
  • Inserted a Front and a Flyer -> Verified Front takes absolute priority.

Documenting

N/A

Further action

  • Future UX Improvement: As a follow-up, it would be great to pass the selected fallback type (e.g., "Flyer") to the React component and display it directly below the image in the sidebar. This would give users better context as to why they are not seeing a standard event poster.

Ticket MBS-13613:
Currently only if an image is a Poster can be shown in SideBar of an event.
This makes it that if no Poster available, a Flyer or next a Banner can be shown.
Copy link
Member

@mwiencek mwiencek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! You should be able to implement this more easily (without additional database queries) by updating $extra_conditions in Data::Role::Art::find_by_entity based on $entity_type. Plus the ORDER BY, so that it sorts things in "poster, flyer, banner" order.

Ticket MBS-13613:
Past method required db queries. It now filters directly on find_by_entity and sorts it following the main hierarchy.
@IvanPisquiy06
Copy link
Author

Thanks for the feedback @mwiencek ! I changed the method following your advice. It was easier as you pointed out, appreciate it!
Let me know your thoughts on this version and thank you for taking the time!

} $art_archive_model->art_archive_type_booleans);

my $extra_conditions = '';
my $order_by = "ORDER BY $art_schema.index_listing.ordering";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're not actually using $order_by anywhere in the query, so there's no sorting right now. (You can also remove ORDER BY from this string and leave it in the query, since it's always present.)

Comment on lines +97 to +100
$extra_conditions .= " AND (is_front = TRUE OR 'Flyer' = ANY($art_schema.index_listing.types) OR 'Banner' = ANY($art_schema.index_listing.types))";

$order_by = "ORDER BY is_front DESC, 'Flyer' = ANY($art_schema.index_listing.types) DESC, 'Banner' = ANY($art_schema.index_listing.types) DESC, $art_schema.index_listing.ordering";
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We try to keep lines under 80 chars. (A lot of existing code does go over that limit, but 193 chars is a bit too excessive.)

Suggested change
$extra_conditions .= " AND (is_front = TRUE OR 'Flyer' = ANY($art_schema.index_listing.types) OR 'Banner' = ANY($art_schema.index_listing.types))";
$order_by = "ORDER BY is_front DESC, 'Flyer' = ANY($art_schema.index_listing.types) DESC, 'Banner' = ANY($art_schema.index_listing.types) DESC, $art_schema.index_listing.ordering";
} else {
my $types_column = "$art_schema.index_listing.types";
$extra_conditions .= 'AND (' .
'is_front = TRUE ' .
"OR 'Flyer' = ANY($types_column) " .
"OR 'Banner' = ANY($types_column)" .
')';
$order_by = 'is_front DESC, ' .
"'Flyer' = ANY($types_column) DESC, " .
"'Banner' = ANY($types_column) DESC, " .
$order_by;
} else {

SQL
}

sub has_artwork_type {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unused.

{eventArtPresence === 'present' ? (
<>
{l('No poster available.')}
{l('No main event art available.')}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of "main," maybe we ought to stick with "front," since that's the prevalent terminology.

Ticket MBS-13613:
The sub has_artwork_type is eliminated and find_by_entity code is cleaned for better organized and cleaner code
@IvanPisquiy06
Copy link
Author

You are right @mwiencek , now that you pointed it out it looks not that well organized and makes the code more readable. Thanks for the tips on making it cleaner. Will definitely apply this in the future.
Appreciate all the guidance on this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants