You are here

public static function ContentAdBase::dimensions in Google AdSense integration 8

Provides the width and height of the ad.

Parameters

string $format: Format of the ad (usually WIDTHxHEIGHT).

Return value

array|null Array with dimensions of the ad, or null if format is not a

5 calls to ContentAdBase::dimensions()
ManagedAd::getAdContent in src/Plugin/AdsenseAd/ManagedAd.php
Return the ad content.
ManagedAd::getAdPlaceholder in src/Plugin/AdsenseAd/ManagedAd.php
Return the ad placeholder.
OldCodeAd::getAdContent in oldcode/src/Plugin/AdsenseAd/OldCodeAd.php
Return the ad content.
OldCodeAd::getAdPlaceholder in oldcode/src/Plugin/AdsenseAd/OldCodeAd.php
Return the ad placeholder.
template_preprocess_adsense_ad in ./adsense.module
Implements template_preprocess_HOOK().

File

src/ContentAdBase.php, line 25

Class

ContentAdBase
Base class for content AdsenseAd plugins.

Namespace

Drupal\adsense

Code

public static function dimensions($format) {
  if (preg_match('!^(\\d+)x(\\d+)(?:_5)?$!', $format, $matches)) {
    return [
      $matches[1],
      $matches[2],
    ];
  }
  return NULL;
}