How is the «Role» list implemented in the «Image Detail» popup on the backend product view?

Context: How is the «Image Detail» popup implemented on the backend product view?

Magento_Catalog::catalog/product/helper/gallery.phtml

958164/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/helper/gallery.phtml#L150-L179

<div class="admin__field field-image-role">
	<label class="admin__field-label">
		<span><?php /* @escapeNotVerified */ echo __('Role')?></span>
	</label>
	<div class="admin__field-control">
		<ul class="multiselect-alt">
			<?php
			foreach ($block->getMediaAttributes() as $attribute) :
				?>
				<li class="item">
					<label>
						<input class="image-type"
							   data-role="type-selector"
							   data-form-part="<?php /* @escapeNotVerified */ echo $formName ?>"
							   type="checkbox"
							   value="<?php /* @escapeNotVerified */ echo $block->escapeHtml(
								   $attribute->getAttributeCode()
							   ) ?>"
							/>
						<?php /* @escapeNotVerified */ echo $block->escapeHtml(
							$attribute->getFrontendLabel()
						) ?>
					</label>
				</li>
			<?php
			endforeach;
			?>
		</ul>
	</div>
</div>

Details: How does \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery\Content::getMediaAttributes() work?

Magento_Catalog/product-gallery::_create()

Magento_Catalog/product-gallery::_getRoles()

Magento_Catalog/product-gallery::_updateImagesRoles()

See also:

backend-product-image-detail-tagged articles