wellcomecollection.org icon indicating copy to clipboard operation
wellcomecollection.org copied to clipboard

Prismic; image dimensions not being queried properly?

Open rcantin-w opened this issue 9 months ago • 10 comments

We'd noticed images dimensions were a bit off following the content migration, for example in search they should all be the same format but aren't anymore:

Image

Then e2e tests flagged that the expected URL for an image wasn't right:


Expected string: "https://images.prismic.io/wellcomecollection/2a42de1c-7954-4ece-be5f-775079c4bc54_Lauren+seated+outside.jpg?auto=compress%2Cformat&rect=0%2C275%2C4000%2C1875&w=800&h=375"
--
  | Received string: "https://images.prismic.io/wellcomecollection/2a42de1c-7954-4ece-be5f-775079c4bc54_Lauren+seated+outside.jpg?auto=format%2Ccompress&rect=&w=800&h="

It seems the rect, w and h is missing, which is probably in line with the first issue. We should figure out why this is happening and fix it.

NB when this ticket is done: playwright/test/article.test.ts > (5) | Articles use the 32:15 crop for their social media preview has been commented out due to Prismic issues with image sizes This will need to be reinstated when Prismic has fixed the issue

rcantin-w avatar May 08 '24 13:05 rcantin-w

See Slack conversation

It seems Prismic's Migration API strips images' crops of their contentUrlSuffix value, which is what is needed to render the correct ratio of image.

Should look like:

 '32:15': {
      contentUrlSuffix: '&rect=0,136,482,226&w=3200&h=1500',
      width: 3200,
      height: 1500
    }

Now looks like:

 '32:15': { contentUrlSuffix: '', width: 3200, height: 1500 }

This is probably something to report to Prismic.

rcantin-w avatar May 08 '24 16:05 rcantin-w

From Prismic:

Ok thanks for sharing, helps a lot, I reached out to the team, these url params should still be there. Not sure why they got stripped.

I imagine this will ultimately require another migration, but don't think we can do anything until we hear more from Prismic.

davidpmccormick avatar May 14 '24 10:05 davidpmccormick

@davidpmccormick Have you heard anything back from Prismic yet? Worth chasing them if not?

pollecuttn avatar May 29 '24 12:05 pollecuttn

https://prismic.atlassian.net/servicedesk/customer/portal/1/PCS-5263

Image

Unfortunately the link in that response (https://prismic.atlassian.net/browse/BT-107) doesn't resolve anywhere useful. I have asked that they point us somewhere where we can keep up-to-date with the status of the bug.

davidpmccormick avatar Jun 20 '24 05:06 davidpmccormick

@davidpmccormick did we ever get that bug link? Wondering if we want to use a FE catchup to brainstorm ideas for this, lmk if useful!

rcantin-w avatar Jul 12 '24 09:07 rcantin-w

Still nothing. I have chased again.

davidpmccormick avatar Jul 15 '24 10:07 davidpmccormick

Currently, we do not have an estimated time for when this issue will be resolved. We’re also reaching out to Atlassian support to understand why you can’t see the open bug. We apologize for any inconvenience these issues may cause.

davidpmccormick avatar Jul 16 '24 06:07 davidpmccormick

When fixed, addressed this TODO in our e2e tests https://github.com/wellcomecollection/wellcomecollection.org/blob/main/playwright/test/article.test.ts#L80

rcantin-w avatar Jul 24 '24 10:07 rcantin-w

We agreed in frontend catch-up that we would give Prismic a month to make progress on the issue themselves. After which time we would take steps to work out whether we can implement our own fix using the crop information from the edit key (and/or manually update as many as we can within an equivalent amount of time)

davidpmccormick avatar Jul 30 '24 11:07 davidpmccormick

The bug has been updated on Prismic's tracker to include a 'bug impact' which they have scored as a 3 ('Feature broken no workaround') out of 6 (1 is the most severe 'API down/repository down' and 6 is 'costmetic'). But there doesn't appear to have been much publicly visible movement on fixing it. It no longer has anyone assigned to it.

They suggested a workaround (open the image cropping tool and resave the document), but that at best doesn't appear to do anything and potentially resulted in the page 500-ing – I've fed this back to Prismic.

I think we might have to investigate our own solution, or take a view on whether we want to manually re-crop (some of) the images. For discussion in frontend catch-up probably.

davidpmccormick avatar Sep 02 '24 13:09 davidpmccormick

I've confirmed that the rect information is surviving a migration by running this article through the script in the prismic-staging environment.

Rather than re-running all of the original migration steps, I think we should be able to check each image id and swap out the crops keys (16:9, 32:15, square) that we have in a snapshot from before the migration.

Anything created after the migration would obviously not be updated, but that shouldn't matter because if it was created in the Prismic UI (rather than through a migration) it should have the rect information

davidpmccormick avatar Oct 08 '24 15:10 davidpmccormick

Rather than re-running all of the original migration steps, I think we should be able to check each image id and swap out the crops keys (16:9, 32:15, square) that we have in a snapshot from before the migration.

That would be an incredible save if we can do that (well done for keeping the snapshots!)

We could trial it on the staging instance first...

rcantin-w avatar Oct 09 '24 15:10 rcantin-w

After migrating the following still need to be done manually. I've notified editorial (and offered to help in a dull moment if they want to split it up).

7 Events

  • https://wellcomecollection.org/events/routes-of-the-kola-nut
  • https://wellcomecollection.org/events/the-beautiful-octopus-club
  • https://wellcomecollection.org/events/careers-in-well-being-and-mental-health
  • https://wellcomecollection.org/events/careers-in-the-arts
  • https://wellcomecollection.org/events/piecing-us-together
  • https://wellcomecollection.org/events/just-add-milk-
  • https://wellcomecollection.org/events/dreaming--old-age--and-melancholia-in-the-early-modern-era

63 Stories

  • https://wellcomecollection.org/articles/a-personal-history-of-albinism
  • https://wellcomecollection.org/articles/renaissance-women-and-their-killer-cosmetics
  • https://wellcomecollection.org/articles/would-you-like-to-buy-a-dinosaur-
  • https://wellcomecollection.org/articles/little-feet-on-pett-level-beach
  • https://wellcomecollection.org/articles/translation
  • https://wellcomecollection.org/articles/audrey-and-her-family
  • https://wellcomecollection.org/articles/the-evil-eye-and-social-anxiety
  • https://wellcomecollection.org/articles/the-cinchona-tree--malaria-and-colonisation
  • https://wellcomecollection.org/articles/me---me
  • https://wellcomecollection.org/articles/a-bad-atmosphere-in-the-balkans
  • https://wellcomecollection.org/articles/ludwig-guttmann-and-the-birth-of-the-paralympics
  • https://wellcomecollection.org/articles/florence-nightingale--victorian-design-and-the-treatment-of-covid-19
  • https://wellcomecollection.org/articles/public-health-campaigns-and-the--threat--of-disability
  • https://wellcomecollection.org/articles/foraging-for-a-taste-of-the-past
  • https://wellcomecollection.org/articles/badger-culling-and-farmers--mental-health
  • https://wellcomecollection.org/articles/writing-the-language-of-music
  • https://wellcomecollection.org/articles/inside-the-minds-of-a-r-hopwood-and-honor-beddard
  • https://wellcomecollection.org/articles/when--get-well-soon--doesn-t-cut-it
  • https://wellcomecollection.org/articles/electric-marvels-in-the-age-of-enlightenment
  • https://wellcomecollection.org/articles/why-are-women-more-willing-donors-than-men-
  • https://wellcomecollection.org/articles/wool--fleas--plague
  • https://wellcomecollection.org/articles/dirt--disease-and-the-inspector-of-nuisances
  • https://wellcomecollection.org/articles/cocaine--the-victorian-wonder-drug
  • https://wellcomecollection.org/articles/backstroke-to-the-future
  • https://wellcomecollection.org/articles/the-unearthly-children-of-science-fiction-s-cold-war
  • https://wellcomecollection.org/articles/fantasies-of-the-future
  • https://wellcomecollection.org/articles/exposing-the-secrets-of-the-human-body
  • https://wellcomecollection.org/articles/challenging-stereotypes-of-people-with-learning-disabilities
  • https://wellcomecollection.org/articles/science-art
  • https://wellcomecollection.org/articles/aids-posters
  • https://wellcomecollection.org/articles/this-is-what-changed-my-approach-to-interior-design
  • https://wellcomecollection.org/articles/we-are-from-here--but-not-from-here
  • https://wellcomecollection.org/articles/digital-pets
  • https://wellcomecollection.org/articles/lustmord-and-the-three-perspectives-of-murder
  • https://wellcomecollection.org/articles/what-is-hysteria
  • https://wellcomecollection.org/articles/how-the-city-lives-inside-me
  • https://wellcomecollection.org/articles/drugs-and-brain-quick-guide-brain-chemistry
  • https://wellcomecollection.org/articles/medics-and-the-bomb
  • https://wellcomecollection.org/articles/why-the-1918-spanish-flu-defied-both-memory-and-imagination
  • https://wellcomecollection.org/articles/above-resistant-pavements-i-floated
  • https://wellcomecollection.org/articles/dear-tooth-fairy
  • https://wellcomecollection.org/articles/when-a-private-pee-is-a-public-disgrace
  • https://wellcomecollection.org/articles/the-evolution-of-war-zone-medicine
  • https://wellcomecollection.org/articles/spanish-flu-and-the-depiction-of-disease
  • https://wellcomecollection.org/articles/obesity-and-britain-s-boys
  • https://wellcomecollection.org/articles/how-we-bury-our-children
  • https://wellcomecollection.org/articles/meet-the-climate-emergency
  • https://wellcomecollection.org/articles/humans--animals-and-the-sensory-world
  • https://wellcomecollection.org/articles/fleeing-fear--defying-prejudice
  • https://wellcomecollection.org/articles/pain-and-the-power-of-activism
  • https://wellcomecollection.org/articles/remote-diagnosis-from-wee-to-the-web
  • https://wellcomecollection.org/articles/medicine-now----then
  • https://wellcomecollection.org/articles/a-portrait-of-me-with-my-mother
  • https://wellcomecollection.org/articles/the-gym-of-cartoon-men
  • https://wellcomecollection.org/articles/confronting-male-stereotypes-in-the-classroom
  • https://wellcomecollection.org/articles/confronting-male-stereotypes-in-the-classroom
  • https://wellcomecollection.org/articles/believe-yourself-better
  • https://wellcomecollection.org/articles/southern-italy-s-centuries-long-dancing-mania
  • https://wellcomecollection.org/articles/when-self-deception-becomes-global-hoax
  • https://wellcomecollection.org/articles/diagnosing-ocd-in-the-past
  • https://wellcomecollection.org/articles/manipulating-the-evidence-with-deepfake-technology
  • https://wellcomecollection.org/articles/inside-the-minds-of-a-r-hopwood-and-honor-beddard
  • https://wellcomecollection.org/articles/the-serious-side-of-historical-games

davidpmccormick avatar Oct 24 '24 08:10 davidpmccormick

@davidpmccormick This is the test I was talking about this morning, it'd just be about uncommenting it (and probably changing the expected values)

rcantin-w avatar Oct 24 '24 11:10 rcantin-w