Skip to content

Commit

Permalink
simplified image handling
Browse files Browse the repository at this point in the history
  • Loading branch information
skripteria committed Nov 28, 2021
1 parent b51587e commit 191137f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ The 'sn' filter then takes 2 parameters:
This is done like this:

```html
<img src="{{ my_image.path | sf('image','This is the hero image on this page')}}" alt='{{ my_image.alt }}'>
<img src="{{ my_image | sf('image','This is the hero image on this page')}}" 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.

Expand Down
6 changes: 5 additions & 1 deletion components/SfPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 1 addition & 3 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down

0 comments on commit 191137f

Please sign in to comment.