diff --git a/README.md b/README.md index 8d94c33..9ae59cd 100644 --- a/README.md +++ b/README.md @@ -62,9 +62,9 @@ The 'sn' filter then takes 2 parameters: This is done like this: ```html - {{ my_image.alt }} + {{ my_image_alt }} ``` - Please note the 'sf' filter needs to be added only once for each image. + Please note the 'sf' filter is only added once in the src attribute, the alt attribute then just uses the same key with the suffix "_alt". - link : for internal Winter CMS links. diff --git a/components/SfPage.php b/components/SfPage.php index 58f7237..78b34d0 100644 --- a/components/SfPage.php +++ b/components/SfPage.php @@ -55,17 +55,21 @@ public function onRun() { switch ($element->type_id) { case 3: if ($element->image) { + $path = $element->image->getPath(); + $img = [ 'path' => $element->image->getPath(), 'alt' => $element->alt ]; } else { + $path = ''; $img = [ 'path' =>'', 'alt' => $element->alt ]; } - $this->page[$element->cms_key] = $img; + $this->page[$element->cms_key] = $path; + $this->page[$element->cms_key.'_alt'] = $element->alt; break; case 5: diff --git a/init.php b/init.php index 760c603..ea6d20c 100644 --- a/init.php +++ b/init.php @@ -14,11 +14,9 @@ function log($message) { function parse_snowflake($templateObject, $objectType, $cleanup = false) { $content = $templateObject->markup; - //log(dump($templateObject)); - // $type: page or partial + preg_match_all('|{{(...*)}}|U', $content, $op); $tags = []; - // log($op); foreach ($op[1] as $key=>$value) {