How to implement a Product Image Switch on the Catalog Category View?

Looking to implement something similar to https://www.kaenon.com/mens.html that alternates the product images based on a query var like: https://www.kaenon.com/mens.html?product_list_gallery=side preferably by adding and using additional image role attributes via the backend

I’ve found this post How is \Magento\Catalog\Block\Product\ImageBuilder implemented and used? but cant find where mage2 decides what image tag