You are here

public static function ManagedAd::adsenseAdFormats in Google AdSense integration 8

This is the array that holds all ad formats.

All it has is a multi-dimensional array indexed by a key, containing the ad type and the description.

To add a new code:

  • Make sure the key is not in use by a different format
  • Go to Google AdSense . Get the dimensions . Get the description

Parameters

string $key: Ad key for which the format is needed (optional).

Return value

array if no key is provided: array of supported ad formats as an array (type, description). if a key is provided, the array containing the ad format for that key, or NULL if there is no ad with that key.

Overrides AdsenseAdInterface::adsenseAdFormats

2 calls to ManagedAd::adsenseAdFormats()
adsense_help_text in help/adsense.help.inc
Creates the help text for the settings tab.
ManagedAdBlock::blockForm in src/Plugin/Block/ManagedAdBlock.php

File

src/Plugin/AdsenseAd/ManagedAd.php, line 196

Class

ManagedAd
Provides an AdSense managed ad unit.

Namespace

Drupal\adsense\Plugin\AdsenseAd

Code

public static function adsenseAdFormats($key = NULL) {
  $ads = [
    'responsive' => [
      'desc' => t('Responsive ad unit'),
    ],
    'custom' => [
      'desc' => t('Custom size ad unit'),
    ],
    'autorelaxed' => [
      'desc' => t('Matched content'),
    ],
    'in-article' => [
      'desc' => t('In-article ad'),
    ],
    'in-feed' => [
      'desc' => t('In-feed ad'),
    ],
    // Top performing ad sizes.
    '300x250' => [
      'desc' => t('Medium Rectangle'),
    ],
    '336x280' => [
      'desc' => t('Large Rectangle'),
    ],
    '728x90' => [
      'desc' => t('Leaderboard'),
    ],
    '300x600' => [
      'desc' => t('Large Skyscraper'),
    ],
    '320x100' => [
      'desc' => t('Large Mobile Banner'),
    ],
    // Other supported ad sizes.
    '320x50' => [
      'desc' => t('Mobile Banner'),
    ],
    '468x60' => [
      'desc' => t('Banner'),
    ],
    '234x60' => [
      'desc' => t('Half Banner'),
    ],
    '120x600' => [
      'desc' => t('Skyscraper'),
    ],
    '120x240' => [
      'desc' => t('Vertical Banner'),
    ],
    '160x600' => [
      'desc' => t('Wide Skyscraper'),
    ],
    '300x1050' => [
      'desc' => t('Portrait'),
    ],
    '970x90' => [
      'desc' => t('Large Leaderboard'),
    ],
    '970x250' => [
      'desc' => t('Billboard'),
    ],
    '250x250' => [
      'desc' => t('Square'),
    ],
    '200x200' => [
      'desc' => t('Small Square'),
    ],
    '180x150' => [
      'desc' => t('Small Rectangle'),
    ],
    '125x125' => [
      'desc' => t('Button'),
    ],
    // 4-links.
    'link' => [
      'desc' => t('Responsive links'),
    ],
    '120x90' => [
      'desc' => t('4-links Vertical Small'),
    ],
    '160x90' => [
      'desc' => t('4-links Vertical Medium'),
    ],
    '180x90' => [
      'desc' => t('4-links Vertical Large'),
    ],
    '200x90' => [
      'desc' => t('4-links Vertical X-Large'),
    ],
    '468x15' => [
      'desc' => t('4-links Horizontal Medium'),
    ],
    '728x15' => [
      'desc' => t('4-links Horizontal Large'),
    ],
  ];
  if (!empty($key)) {
    return array_key_exists($key, $ads) ? $ads[$key] : NULL;
  }
  else {
    return $ads;
  }
}