<?php

namespace TSNV_SEO;

$alt_title_config = array(); // '' => array('alt' => ''), or '' => array('alt' => '', 'title' => ''),

$alt_title_config['azurslotczech.com'] = array(
  'https://azurslotczech.com/wp-content/themes/azurslot/assets/img/footer/arrow.png' => array('alt' => 'Top'),
  'https://azurslotczech.com/wp-content/themes/azurslot/assets/img/faq/arrow-down.png' => array('alt' => 'FAQ'),
  'https://azurslotczech.com/wp-content/themes/azurslot/assets/img/features/icon.png' => array('alt' => 'Výhody Azur Slot'),
  'https://azurslotczech.com/wp-content/themes/azurslot/assets/img/app/android.png' => array('alt' => 'Azur Slot Android'),
  'https://azurslotczech.com/wp-content/themes/azurslot/assets/img/app/apple.svg' => array('alt' => 'Azur Slot iOS'),
  'https://azurslotczech.com/wp-content/themes/azurslot/assets/img/app/logo.png' => array('alt' => 'Azur Slot'),
);

$alt_title_config['azurslotnorway.com'] = array(
  'https://azurslotnorway.com/wp-content/themes/azurslot/assets/img/features/num1.png' => array('alt' => '01'),
  'https://azurslotnorway.com/wp-content/themes/azurslot/assets/img/features/num2.png' => array('alt' => '02'),
  'https://azurslotnorway.com/wp-content/themes/azurslot/assets/img/features/num3.png' => array('alt' => '03'),
  'https://azurslotnorway.com/wp-content/themes/azurslot/assets/img/features/num4.png' => array('alt' => '04'),
  'https://azurslotnorway.com/wp-content/themes/azurslot/assets/img/features/num5.png' => array('alt' => '05'),
  'https://azurslotnorway.com/wp-content/themes/azurslot/assets/img/features/num6.png' => array('alt' => '06'),
  'https://azurslotnorway.com/wp-content/themes/azurslot/assets/img/rating/divider.png' => array('alt' => 'Azur Slot-vurderinger'),
  'https://azurslotnorway.com/wp-content/themes/azurslot/assets/img/footer/arrow-small.png' => array('alt' => 'Arrow'),
  'https://azurslotnorway.com/wp-content/themes/azurslot/assets/img/banner-section/icon.png' => array('alt' => 'Azur Slot Casino'),
  'https://azurslotnorway.com/wp-content/themes/azurslot/assets/img/header/norway.png' => array('alt' => 'Norge'),
  'https://azurslotnorway.com/wp-content/themes/azurslot/assets/img/banner-section/divider.png' => array('alt' => 'Azur Slot'),
  'https://azurslotnorway.com/wp-content/themes/azurslot/assets/img/faq/arrow-down.png' => array('alt' => 'FAQ'),
  'https://azurslotnorway.com/wp-content/themes/azurslot/assets/img/footer/arrow.png' => array('alt' => 'Top'),
  'https://azurslotnorway.com/wp-content/themes/azurslot/assets/img/app/App.png' => array('alt' => 'Azur Slot iOS'),
  'https://azurslotnorway.com/wp-content/themes/azurslot/assets/img/app/Google.png' => array('alt' => 'Azur Slot Android'),
);

$alt_title_config['tritonslots.hu'] = array(
  'https://tritonslots.hu/wp-content/themes/tritonslots/assets/images/icons/header-button-icon-white.png' => array('alt' => 'Regisztráció'),
  'https://tritonslots.hu/wp-content/themes/tritonslots/assets/images/icons/header-button-icon-black.svg' => array('alt' => 'Bejelentkezés'),
);

$alt_title_config['tritonslots-de.com'] = array(
  'https://tritonslots-de.com/wp-content/themes/tritonslots/assets/img/flags/de.png' => array('alt' => 'Deutschland'),
  'https://tritonslots-de.com/wp-content/themes/tritonslots/assets/img/table.svg' => array('alt' => 'Table'),
  'https://tritonslots-de.com/wp-content/themes/tritonslots/assets/img/app.svg' => array('alt' => 'Triton Slots iOS'),
  'https://tritonslots-de.com/wp-content/themes/tritonslots/assets/img/android.svg' => array('alt' => 'Triton Slots Android'),
  'https://tritonslots-de.com/wp-content/themes/tritonslots/assets/img/app.png' => array('alt' => 'Triton Slots App'),
);

$alt_title_config['triton-slots.ch'] = array(
  'https://triton-slots.ch/wp-content/themes/tritonslots/assets/img/down.svg' => array('alt' => 'Down'),
  'https://triton-slots.ch/wp-content/themes/tritonslots/assets/img/cto.softlabs_aquamen.png' => array('alt' => 'Triton Slots'),
  'https://triton-slots.ch/wp-content/themes/tritonslots/assets/img/flag.png' => array('alt' => 'Schweiz'),
  'https://triton-slots.ch/wp-content/themes/tritonslots/assets/img/Frame2115534173.svg' => array('alt' => 'Arrow'),
  'https://triton-slots.ch/wp-content/themes/tritonslots/assets/img/Icons.svg' => array('alt' => 'Icon'),
  'https://triton-slots.ch/wp-content/themes/tritonslots/assets/img/down1.svg' => array('alt' => 'Down'),
  'https://triton-slots.ch/wp-content/themes/tritonslots/assets/img/img1.png' => array('alt' => 'Triton Slots'),
  'https://triton-slots.ch/wp-content/themes/tritonslots/assets/img/apple.svg' => array('alt' => 'Triton Slots iOS'),
  'https://triton-slots.ch/wp-content/themes/tritonslots/assets/img/iPhone-12-Pro-mockup.png' => array('alt' => 'Triton Slots App'),
  'https://triton-slots.ch/wp-content/themes/tritonslots/assets/img/Frame14372544961.png' => array('alt' => 'Triton Slots App'),
  'https://triton-slots.ch/wp-content/themes/tritonslots/assets/img/android.svg' => array('alt' => 'Triton Slots Android'),
  'https://triton-slots.ch/wp-content/themes/tritonslots/assets/img/logo1.png' => array('alt' => 'Triton Slots'),
);

$alt_title_config['triton-slots.de'] = array(
  'https://triton-slots.de/wp-content/themes/tritonslots/assets/img/footer/arrow.png' => array('alt' => 'Arrow'),
  'https://triton-slots.de/wp-content/themes/tritonslots/assets/img/features/icon.png' => array('alt' => 'Triton Slots Vorteile'),
  'https://triton-slots.de/wp-content/themes/tritonslots/assets/img/header/ge.png' => array('alt' => 'Deutschland'),
  'https://triton-slots.de/wp-content/themes/tritonslots/assets/img/app/android.png' => array('alt' => 'Triton Slots Android'),
  'https://triton-slots.de/wp-content/themes/tritonslots/assets/img/app/apple.png' => array('alt' => 'Triton Slots iOS'),
);

$alt_title_config['tritonslots.de'] = array(
  'https://tritonslots.de/wp-content/themes/tritonslots/assets/img/rating/star.png' => array('alt' => 'Bewertung'),
  'https://tritonslots.de/wp-content/themes/tritonslots/assets/img/rating/star-grey.png' => array('alt' => 'Star'),
  'https://tritonslots.de/wp-content/themes/tritonslots/assets/img/header/ge.png' => array('alt' => 'Deutschland'),
  'https://tritonslots.de/wp-content/themes/tritonslots/assets/img/features/icon.png' => array('alt' => 'Icon'),
  'https://tritonslots.de/wp-content/themes/tritonslots/assets/img/footer/arrow.png' => array('alt' => 'Arrow'),
  'https://tritonslots.de/wp-content/themes/tritonslots/assets/img/app/apple.png' => array('alt' => 'Triton Slots iOS'),
  'https://tritonslots.de/wp-content/themes/tritonslots/assets/img/app/android.png' => array('alt' => 'Triton Slots Android'),
);

$alt_title_config['triton-slots.at'] = array(
  'https://triton-slots.at/wp-content/themes/tritonslots/assets/images/icon-arrow-to-top.svg' => array('alt' => 'Arrow'),
  'https://triton-slots.at/wp-content/themes/tritonslots/assets/images/icon-table.svg' => array('alt' => 'Icon'),
  'https://triton-slots.at/wp-content/themes/tritonslots/assets/images/flag.png' => array('alt' => 'Österreich'),
  'https://triton-slots.at/wp-content/themes/tritonslots/assets/images/app-img-right.svg' => array('alt' => 'Triton Slots'),
  'https://triton-slots.at/wp-content/themes/tritonslots/assets/images/icon-android.svg' => array('alt' => 'Triton Slots Android'),
  'https://triton-slots.at/wp-content/themes/tritonslots/assets/images/icon-apple.svg' => array('alt' => 'Triton Slots iOS'),
);

$alt_title_config['tritonslots.at'] = array(
  'https://tritonslots.at/wp-content/themes/tritonslots/assets/images/icons/star2.svg' => array('alt' => 'Srtar'),
  'https://tritonslots.at/wp-content/themes/tritonslots/assets/images/icons/about-icon.svg' => array('alt' => 'About'),
  'https://tritonslots.at/wp-content/themes/tritonslots/assets/images/icons/up.svg' => array('alt' => 'Up'),
  'https://tritonslots.at/wp-content/themes/tritonslots/assets/images/icons/star1.svg' => array('alt' => 'Rating'),
  'https://tritonslots.at/wp-content/themes/tritonslots/assets/images/app-logo.svg' => array('alt' => 'Triton Slots'),
  'https://tritonslots.at/wp-content/themes/tritonslots/assets/images/icons/android.svg' => array('alt' => 'Triton Slots Android'),
  'https://tritonslots.at/wp-content/themes/tritonslots/assets/images/icons/apple.svg' => array('alt' => 'Triton Slots iOS'),
);

$alt_title_config['azurslotespana.com'] = array(
  'https://azurslotespana.com/wp-content/themes/azurslot/assets/img/features/decor.png' => array('alt' => 'Decor'),
  'https://azurslotespana.com/wp-content/themes/azurslot/assets/img/features/icon.png' => array('alt' => 'Ventajas'),
  'https://azurslotespana.com/wp-content/themes/azurslot/assets/img/footer/arrow.png' => array('alt' => 'Arrow'),
  'https://azurslotespana.com/wp-content/themes/azurslot/assets/img/faq/plus.png' => array('alt' => 'FAQ'),
  'https://azurslotespana.com/wp-content/themes/azurslot/assets/img/sidebar/decor.png' => array('alt' => 'Decor'),
  'https://azurslotespana.com/wp-content/themes/azurslot/assets/img/app/Google.png' => array('alt' => 'Azur Slot Android'),
  'https://azurslotespana.com/wp-content/themes/azurslot/assets/img/app/App.png' => array('alt' => 'Azur Slot iOS'),
  'https://azurslotespana.com/wp-content/themes/azurslot/assets/img/app/logo-app.png' => array('alt' => 'Azur Slot'),
);

$alt_title_config['triton-slots.jp'] = array(
  'https://triton-slots.jp/wp-content/themes/tritonslots/assets/img/Flag.png' => array('alt' => '日本'),
  'https://triton-slots.jp/wp-content/themes/tritonslots/assets/img/icon-list.svg' => array('alt' => '利点'),
  'https://triton-slots.jp/wp-content/themes/tritonslots/assets/img/apple.svg' => array('alt' => 'Triton Slots iOS'),
  'https://triton-slots.jp/wp-content/themes/tritonslots/assets/img/android.svg' => array('alt' => 'Triton Slots Android'),
);

$alt_title_config['azurslot-spain.com'] = array(
  'https://azurslot-spain.com/wp-content/themes/azurslot/assets/img/footer/arrow.png' => array('alt' => 'Arrow'),
  'https://azurslot-spain.com/wp-content/themes/azurslot/assets/img/features/icon.png' => array('alt' => 'Icon'),
  'https://azurslot-spain.com/wp-content/themes/azurslot/assets/img/banner-section/icon.png' => array('alt' => 'Icon'),
  'https://azurslot-spain.com/wp-content/themes/azurslot/assets/img/faq/arrow-down.png' => array('alt' => 'Arrow'),
  'https://azurslot-spain.com/wp-content/themes/azurslot/assets/img/header/flag.png' => array('alt' => 'Spain'),
  'https://azurslot-spain.com/wp-content/themes/azurslot/assets/img/app/Google.png' => array('alt' => 'Azur Slot Android'),
  'https://azurslot-spain.com/wp-content/themes/azurslot/assets/img/app/apple.svg' => array('alt' => 'Azur Slot iOS'),
  'https://azurslot-spain.com/wp-content/themes/azurslot/assets/img/app/logo.png' => array('alt' => 'Azur Slot'),
);

$alt_title_config['es-azurslot.com'] = array(
  'https://es-azurslot.com/wp-content/themes/azurslot/assets/img/aside.svg' => array('alt' => 'Side'),
  'https://es-azurslot.com/wp-content/themes/azurslot/assets/img/table.svg' => array('alt' => 'Table'),
  'https://es-azurslot.com/wp-content/themes/azurslot/assets/img/to-top.svg' => array('alt' => 'Top'),
  'https://es-azurslot.com/wp-content/themes/azurslot/assets/img/lg.svg' => array('alt' => 'Element'),
  'https://es-azurslot.com/wp-content/themes/azurslot/assets/img/flag-es.png' => array('alt' => 'España'),
  'https://es-azurslot.com/wp-content/themes/azurslot/assets/img/android.svg' => array('alt' => 'Azur Slot Android'),
  'https://es-azurslot.com/wp-content/themes/azurslot/assets/img/apple.svg' => array('alt' => 'Azur Slot iOS'),
);

$alt_title_config['azurslot-nz.com'] = array(
  'https://azurslot-nz.com/wp-content/themes/azurslot/assets/img/icon-list.svg' => array('alt' => 'Icon'),
);

$alt_title_config['azurslot.co.nz'] = array(
  'https://azurslot.co.nz/wp-content/themes/azurslot/assets/img/features/icon.png' => array('alt' => 'Icon'),
  'https://azurslot.co.nz/wp-content/themes/azurslot/assets/img/banner-section/decor.png' => array('alt' => 'Decor'),
  'https://azurslot.co.nz/wp-content/themes/azurslot/assets/img/rating/star.png' => array('alt' => 'Star'),
  'https://azurslot.co.nz/wp-content/themes/azurslot/assets/img/faq/arrow-down.png' => array('alt' => 'Arrow'),
  'https://azurslot.co.nz/wp-content/themes/azurslot/assets/img/app/apple.png' => array('alt' => 'Azur Slot iOS'),
  'https://azurslot.co.nz/wp-content/themes/azurslot/assets/img/app/android.png' => array('alt' => 'Azur Slot Android'),
  'https://azurslot.co.nz/wp-content/themes/azurslot/assets/img/app/logo-app.png' => array('alt' => 'Azur Slot App'),
);

$alt_title_config['tritonslotsczech.com'] = array(
  'https://tritonslotsczech.com/wp-content/themes/tritonslots/assets/img/table.svg' => array('alt' => 'Triton Slots'),
  'https://tritonslotsczech.com/wp-content/themes/tritonslots/assets/img/sidebar-arrow.svg' => array('alt' => 'Arrow'),
  'https://tritonslotsczech.com/wp-content/themes/tritonslots/assets/img/flags/cz.png' => array('alt' => 'Czech'),
  'https://tritonslotsczech.com/wp-content/themes/tritonslots/assets/img/footer-icon.svg' => array('alt' => 'Casino'),
  'https://tritonslotsczech.com/wp-content/themes/tritonslots/assets/img/logo.svg' => array('alt' => 'Triton Slots'),
  'https://tritonslotsczech.com/wp-content/themes/tritonslots/assets/img/app.svg' => array('alt' => 'App'),
  'https://tritonslotsczech.com/wp-content/themes/tritonslots/assets/img/app.png' => array('alt' => 'App'),
  'https://tritonslotsczech.com/wp-content/themes/tritonslots/assets/img/android.svg' => array('alt' => 'Android'),
);

$alt_title_config['22bit.cz'] = array(
  'https://22bit.cz/wp-content/themes/22bit/assets/img/table.svg' => array('alt' => '22Bit'),
  'https://22bit.cz/wp-content/themes/22bit/assets/img/android.svg' => array('alt' => 'Android'),
  'https://22bit.cz/wp-content/themes/22bit/assets/img/ios.svg' => array('alt' => 'iOS'),
  'https://22bit.cz/wp-content/themes/22bit/assets/img/footer-arrow.svg' => array('alt' => 'Arrow'),
  'https://22bit.cz/wp-content/themes/22bit/assets/img/flags/cz.png' => array('alt' => 'Czech'),
  'https://22bit.cz/wp-content/themes/22bit/assets/img/logo.png' => array('alt' => '22Bit'),
  'https://22bit.cz/wp-content/themes/22bit/assets/img/apple.svg' => array('alt' => 'Apple'),
  'https://22bit.cz/wp-content/themes/22bit/assets/img/app.png' => array('alt' => 'App'),
);

$alt_title_config['tritonslots-nz.com'] = array(
  'https://tritonslots-nz.com/wp-content/themes/tritonslots/assets/images/icons/sidebar-arrow.svg' => array('alt' => 'Arrow'),
  'https://tritonslots-nz.com/wp-content/themes/tritonslots/assets/images/icons/about-icon.svg' => array('alt' => 'About'),
  'https://tritonslots-nz.com/wp-content/themes/tritonslots/assets/images/icons/up.svg' => array('alt' => 'Arrow'),
  'https://tritonslots-nz.com/wp-content/themes/tritonslots/assets/images/icons/apple.svg' => array('alt' => 'Apple'),
  'https://tritonslots-nz.com/wp-content/themes/tritonslots/assets/images/icons/android.svg' => array('alt' => 'Android'),
);

$alt_title_config['tritonslotsaustralia.com'] = array(
  'https://tritonslotsaustralia.com/wp-content/themes/tritonslots/assets/img/Frame.svg' => array('alt' => 'Check'),
  'https://tritonslotsaustralia.com/wp-content/themes/tritonslots/assets/img/Frame35457.svg' => array('alt' => 'Plus'),
  'https://tritonslotsaustralia.com/wp-content/themes/tritonslots/assets/img/Frame35459.svg' => array('alt' => 'Minus'),
  'https://tritonslotsaustralia.com/wp-content/themes/tritonslots/assets/img/Layer_1.svg' => array('alt' => 'Bonus'),
  'https://tritonslotsaustralia.com/wp-content/themes/tritonslots/assets/img/Lightning2.png' => array('alt' => 'Triton Slots'),
  'https://tritonslotsaustralia.com/wp-content/themes/tritonslots/assets/img/dwarf_mine_character_021.png' => array('alt' => 'Triton Slots'),
  'https://tritonslotsaustralia.com/wp-content/themes/tritonslots/assets/img/down.svg' => array('alt' => 'Triton Slots'),
  'https://tritonslotsaustralia.com/wp-content/themes/tritonslots/assets/img/Lightning1.png' => array('alt' => 'Triton Slots'),
  'https://tritonslotsaustralia.com/wp-content/themes/tritonslots/assets/img/Frame(1).svg' => array('alt' => 'Arrow'),
  'https://tritonslotsaustralia.com/wp-content/themes/tritonslots/assets/img/AU.svg' => array('alt' => 'AU'),
  'https://tritonslotsaustralia.com/wp-content/themes/tritonslots/assets/img/android.svg' => array('alt' => 'Android'),
  'https://tritonslotsaustralia.com/wp-content/themes/tritonslots/assets/img/apple.svg' => array('alt' => 'iOS'),
  'https://tritonslotsaustralia.com/wp-content/themes/tritonslots/assets/img/logo(1).png' => array('alt' => 'Triton Slots'),
  'https://tritonslotsaustralia.com/wp-content/themes/tritonslots/assets/img/magic11.png' => array('alt' => 'Triton Slots'),
  'https://tritonslotsaustralia.com/wp-content/themes/tritonslots/assets/img/iPhone12Pro-mockup.png' => array('alt' => 'IPhone'),
  'https://tritonslotsaustralia.com/wp-content/themes/tritonslots/assets/img/image20581.png' => array('alt' => 'Triton Slots'),
);

$alt_title_config['tritonslots.com.gr'] = array(
  'https://tritonslots.com.gr/wp-content/themes/tritonslots/assets/img/Chevronup(1).svg' => array('alt' => 'Triton Slots'),
  'https://tritonslots.com.gr/wp-content/themes/tritonslots/assets/img/solar_shield-up-outline.png' => array('alt' => 'Triton Slots'),
  'https://tritonslots.com.gr/wp-content/themes/tritonslots/assets/img/Chevronup.svg' => array('alt' => 'Triton Slots'),
  'https://tritonslots.com.gr/wp-content/themes/tritonslots/assets/img/solar_star-bold.svg' => array('alt' => 'Triton Slots'),
  'https://tritonslots.com.gr/wp-content/themes/tritonslots/assets/img/Flag.svg' => array('alt' => 'Greece'),
  'https://tritonslots.com.gr/wp-content/themes/tritonslots/assets/img/020-money-bag.svg' => array('alt' => 'Money'),
  'https://tritonslots.com.gr/wp-content/themes/tritonslots/assets/img/android.svg' => array('alt' => 'Android'),
  'https://tritonslots.com.gr/wp-content/themes/tritonslots/assets/img/apple.svg' => array('alt' => 'Apple'),
  'https://tritonslots.com.gr/wp-content/themes/tritonslots/assets/img/shutterstock_25534836051.png' => array('alt' => 'Triton Slots'),
);

$alt_title_config['azurslot-greece.com'] = array(
  'https://azurslot-greece.com/wp-content/themes/azurslot/assets/img/banner-section/decor.png' => array('alt' => 'Decor'),
  'https://azurslot-greece.com/wp-content/themes/azurslot/assets/img/features/icon.png' => array('alt' => 'Πλεονέκτημα'),
  'https://azurslot-greece.com/wp-content/themes/azurslot/assets/img/faq/arrow-down.png' => array('alt' => 'Arrow'),
  'https://azurslot-greece.com/wp-content/themes/azurslot/assets/img/app/android.png' => array('alt' => 'AzurSlot Android'),
  'https://azurslot-greece.com/wp-content/themes/azurslot/assets/img/app/apple.svg' => array('alt' => 'AzurSlot Apple'),
  'https://azurslot-greece.com/wp-content/themes/azurslot/assets/img/footer/arrow.png' => array('alt' => 'Arrow'),
  'https://azurslot-greece.com/wp-content/themes/azurslot/assets/img/app/logo.png' => array('alt' => 'AzurSlot'),
);


add_action('template_redirect', function () {
  ob_start(__NAMESPACE__ . '\\fix_image_alt_title');
});

function fix_image_alt_title($html) {
  global $alt_title_config;

  $host = $_SERVER['HTTP_HOST'] ?? '';
  if (!isset($alt_title_config[$host])) {
    return $html;
  }

  $image_map = $alt_title_config[$host];

  $html = preg_replace_callback(
    '/<img[^>]+src=["\']([^"\']+)["\'][^>]*>/i',
    function ($matches) use ($image_map) {
      $img_tag = $matches[0];
      $src = $matches[1];

      if (!isset($image_map[$src])) {
        return $img_tag;
      }

      $alt = esc_attr($image_map[$src]['alt'] ?? '');
      $title = esc_attr($image_map[$src]['title'] ?? $alt);

      // 1. Remove alt and title in any form
      $img_tag = preg_replace('/\s+(alt|title)(\s*=\s*("|\')?.*?\3)?/i', '', $img_tag);

      // 2. Remove possible single closings before >
      $img_tag = preg_replace('/\s*\/?>\s*$/', '', $img_tag);

      // 3. Add normalized alt and title
      $img_tag .= ' alt="' . esc_attr($alt) . '" title="' . esc_attr($title) . '">';

      return $img_tag;
    },
    $html
  );

  return $html;
}


