Sensible way to rewrite a field for all views in Drupal 8? In Drupal 8 seems one has to create 2 or 3 files plus folder structures to do even the simplest of tasks. So I am trying to figure out how to do a simple hack without all the overhead. 

I have a node type for which I attached images. There is a parent node for which I want to display one of the images from the children. I created an Image field for the parent. 

So literally, all I need to do is query the database, grab a child's image at random (in every view, each time the parent is viewed, I want the image re-assigned randomly), and rewrite the parent's image field accordingly. This was so easy in Drupal 7...

Does anyone have an idea of how to do this in Drupal 8 in the simplest possible manner, ideally editing just one file?

Thanks!
You can use hooks the same way as in Drupal 7, if you want to change the content of the node before rendering, you can put a hook in your module or theme:

module/theme_preprocess(&amp;$variables, $hook) {
   if ($hook == 'node') {
      ...


check if you are in the right node and change it.

The simplest solution for your problem would be to put all children images in the node display and then hide the images you don't want:

hide($variables['content']['field_image_?']);


So you don't need to lookup the children image yourself.