Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prioritise replacement images over cutouts #278

Merged
merged 5 commits into from
Oct 20, 2022

Conversation

jonathonherbert
Copy link
Contributor

What does this change?

Per @davidfurey's suggestion in an out-of-band discussion, this PR prioritises resolving image replacements over cutouts when we're getting images from trail meta.

This solves a problem where, for content with the Comment tone, replacement images are being ignored in favour of cutouts. This happens because we set imageCutoutReplace automatically when we encounter that tone.

AFAICS we don't set imageReplace automatically within this repo, and facia-tool sets that value exclusively of imageCutoutReplace (when one image value is true, the others are not), so we should not run into problems where this priority is incorrect.

Dev notes

It's worth noting that this might not be the most comprehensive way of solving this problem – I'm fairly convinced it'd be better to make the decision about tags and defaults in the Fronts tool, and pass those decisions down as data –

  • It puts the decision making for this sort of thing in one place
  • It makes it clear what's going to happen in the UI of the Fronts tool, which will display the cutout if applied, etc.

A previous PR attempting to solve this problem took the above approach, but was reverted as the changes required were more involved and would have required some co-ordination.

This codebase moves slowly, and this is a problem that's come up a few times recently, so I think this is a good patch even if we end taking the above approach in the future.

How to test

  • I've added a unit test which will fail with the old code in place.
  • Import this library into facia-press, perhaps via a snapshot release, deploy, and add a piece with a Comment tone to a front in CODE. Prior to this change, you will not be able to replace the image in the fronts tool. After it, that should work.

How can we measure success?

Fewer editorial complaints about unexpected behaviour.

Copy link

@twrichards twrichards left a comment

Choose a reason for hiding this comment

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

logic looks good and lovely tests (and PR description) - I've not tested but PR makes total sense and assume you've tested end-to-end

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.

3 participants