/**
  * Alter the options and set an image as label
  *
  * @param IsotopeProduct|Product\Standard $objProduct
  *
  * @return array|mixed
  *
  * @throws \InvalidArgumentException when optionsSource=product but product is null
  * @throws \UnexpectedValueException for unknown optionsSource
  */
 public function getOptionsForWidget(IsotopeProduct $objProduct = null)
 {
     // Skip in the back end or without a given product
     if (TL_MODE == 'BE' || null === $objProduct) {
         return parent::getOptionsForWidget($objProduct);
     }
     // Fetch all product's variants and make the accessible via the attribute value in an array
     $objVariants = Product::findAvailableByIds($objProduct->getVariantIds());
     if (null === $objVariants) {
         return parent::getOptionsForWidget($objProduct);
     }
     /** @var IsotopeProduct[] $arrVariants */
     $arrVariants = array_combine($objVariants->fetchEach($this->field_name), $objVariants->getModels());
     // Alter the options
     return array_map(function ($arrOption) use($arrVariants) {
         // Skip if option has no associated product variant
         if (!array_key_exists($arrOption['value'], $arrVariants)) {
             return $arrOption;
         }
         /** @var Gallery|Gallery\Standard $objGallery */
         $objGallery = Gallery::createForProductAttribute($arrVariants[$arrOption['value']], 'images', array('gallery' => $this->radioImageGallery));
         // Wrap label in span with css class
         $arrOption['label'] = sprintf('<span class="attribute-label">%s</span>', $arrOption['label']);
         // Add image to label
         $arrOption['label'] .= PHP_EOL . $objGallery->generateMainImage();
         return $arrOption;
     }, parent::getOptionsForWidget($objProduct));
 }