From 142fc48b00374e5289a3b6ea97a0e1c0e6b00188 Mon Sep 17 00:00:00 2001 From: Tony Air Date: Tue, 7 Sep 2021 23:24:57 +0200 Subject: [PATCH] FIX: Slider size on missing owner element --- src/Extensions/SlideImageExtension.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Extensions/SlideImageExtension.php b/src/Extensions/SlideImageExtension.php index 941be09..a3fc05f 100755 --- a/src/Extensions/SlideImageExtension.php +++ b/src/Extensions/SlideImageExtension.php @@ -9,6 +9,7 @@ namespace A2nt\CMSNiceties\Extensions; +use A2nt\ElementalBasics\Elements\SliderElement; use SilverStripe\Forms\CheckboxField; use SilverStripe\Forms\DatetimeField; use SilverStripe\Forms\FieldList; @@ -37,12 +38,20 @@ class SlideImageExtension extends DataExtension public function getSlideWidth() { $element = $this->getElement(); + if(!$element->ID) { + return SliderElement::config()->get('slide_width'); + } + return $element->getSlideWidth(); } public function getSlideHeight() { $element = $this->getElement(); + if(!$element->ID) { + return SliderElement::config()->get('slide_height'); + } + return $element->getSlideHeight(); }