hasComponentAttribute($widthName)) { $widthValue = trim($attributes->getValueAndRemove($widthName)); if ($widthValue == "0") { /** * For an image, the dimension are restricted by height */ if ($attributes->hasComponentAttribute(self::HEIGHT_KEY)) { $attributes->addStyleDeclarationIfNotSet("width", "auto"); } } else { if ($widthValue == "fit") { $widthValue = "fit-content"; } else { /** Numeric value */ $widthValue = TagAttributes::toQualifiedCssValue($widthValue); } /** * For an image (png, svg) * They have width and height **element** attribute */ if (in_array($attributes->getLogicalTag(), self::NATURAL_SIZING_ELEMENT)) { /** * If the image is not ask as static resource (ie HTTP request) * but added in HTML * (ie {@link \action_plugin_combo_svg}) */ $requestedMime = $attributes->getMime(); if ($requestedMime == TagAttributes::TEXT_HTML_MIME) { $attributes->addStyleDeclarationIfNotSet('max-width', $widthValue); $attributes->addStyleDeclarationIfNotSet('width', "100%"); } } else { /** * For a block */ $attributes->addStyleDeclarationIfNotSet('max-width', $widthValue); } } } $heightName = self::HEIGHT_KEY; if ($attributes->hasComponentAttribute($heightName)) { $heightValue = trim($attributes->getValueAndRemove($heightName)); if ($heightValue !== "") { $heightValue = TagAttributes::toQualifiedCssValue($heightValue); if (in_array($attributes->getLogicalTag(), self::NATURAL_SIZING_ELEMENT)) { /** * A element with a natural height is responsive, we set only the max-height * * By default, the image has a `height: auto` due to the img-fluid class * Making its height responsive */ $attributes->addStyleDeclarationIfNotSet("max-height", $heightValue); } else { /** * HTML Block * * Without the height value, a block display will collapse */ if (self::HEIGHT_LAYOUT_DEFAULT == self::DESIGN_LAYOUT_CONSTRAINED) { /** * The box is constrained in height * By default, a box is not constrained */ $attributes->addStyleDeclarationIfNotSet("height", $heightValue); $scrollMechanism = $attributes->getValueAndRemoveIfPresent("scroll"); if ($scrollMechanism != null) { $scrollMechanism = trim(strtolower($scrollMechanism)); } switch ($scrollMechanism) { case "toggle": // https://jsfiddle.net/gerardnico/h0g6xw58/ $attributes->addStyleDeclarationIfNotSet("overflow-y", "hidden"); $attributes->addStyleDeclarationIfNotSet("position", "relative"); $attributes->addStyleDeclarationIfNotSet("display", "block"); // The block should collapse to this height $attributes->addStyleDeclarationIfNotSet("min-height", $heightValue); if ($attributes->hasComponentAttribute("id")) { $id = $attributes->getValue("id"); } else { $id = $attributes->generateAndSetId(); } /** * Css of the button and other standard attribute */ PluginUtility::getSnippetManager()->attachCssInternalStyleSheetForSlot("height-toggle"); /** * Set the color dynamically to the color of the parent */ PluginUtility::getSnippetManager()->attachInternalJavascriptForSlot("height-toggle"); /** * The height when there is not the show class * is the original height */ $css = <<attachCssInternalStyleSheetForSlot("height-toggle-show", $css); $bootstrapDataNameSpace = Bootstrap::getDataNamespace(); $button = <<