Commit 89e05277 authored by neffets's avatar neffets
Browse files

Issue #3285097: allow vh and wh units in width and height values

parent 69c14a58
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ class IframeWidgetBase extends WidgetBase {
   * Translate the description for iframe width/height only once.
   */
  protected static function getSizedescription() {
    return t('The iframe\'s width and height can be set in pixels as a number only ("500" for 500 pixels) or in a percentage value followed by the percent symbol (%) ("50%" for 50 percent).');
    return t('The iframe\'s width and height can be set in pixels as a number only ("500" for 500 pixels) or in a percentage value followed by the percent symbol (%) ("50%" for 50 percent), further supported for width em/rem/vw and for height em/rem/vh.');
  }

  /**
@@ -350,7 +350,7 @@ class IframeWidgetBase extends WidgetBase {

    // \iframe_debug(0, 'validateWidth', $me);
    if (!empty($me['url']) && isset($me['width'])) {
      if (empty($me['width']) || !preg_match('#^(\d+\%?|auto)$#', $me['width'])) {
      if (empty($me['width']) || !preg_match('#^(\d+(?:\%|em|rem|vw)?|auto)$#', $me['width'])) {
        $form_state->setError($form, self::getSizedescription());
      }
    }
@@ -368,7 +368,7 @@ class IframeWidgetBase extends WidgetBase {

    // \iframe_debug(0, 'validateHeight', $me);
    if (!empty($me['url']) && isset($me['height'])) {
      if (empty($me['height']) || !preg_match('#^(\d+\%?|auto)$#', $me['height'])) {
      if (empty($me['height']) || !preg_match('#^(\d+(?:\%|em|rem|vh)?|auto)$#', $me['height'])) {
        $form_state->setError($form, self::getSizedescription());
      }
    }