I need to put an image field url into the header meta tag (open graph image). The obvious ways to put things in the header are in html.html.twig, hook_preprocess_html, and hook_page_attachments. But in any of these, how do I access the content to be rendered in order to see what the image url is?
And this is complicated by the fact that the rendered entity is a commerce product, while the desired image field is on the product_variation entity, with drupal commerce rendering the desired variation using a query string and an EntityViewBulder::alterBuild.
This means I can't use e.g. $product = \Drupal::routeMatch()->getParameter('commerce_product') because we wouldn't know what variation is being shown.
Once the variation is to be had, it would be fine to get the delta 0 image from the image field on the variation.