@parameter1/base-cms-marko-web 3.7.7 → 3.7.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
|
|
1
|
-
import { getAsArray } from "@parameter1/base-cms-object-path";
|
1
|
+
import { getAsArray, getAsObject } from "@parameter1/base-cms-object-path";
|
2
|
+
import imageHeight from "../../node/utils/image-height";
|
2
3
|
|
3
4
|
$ const { config } = out.global;
|
4
5
|
$ const { src, alt } = input;
|
@@ -7,10 +8,16 @@ $ const srcset = getAsArray(input.srcset).join(", ") || null;
|
|
7
8
|
|
8
9
|
$ const classNames = [input.class];
|
9
10
|
$ if (lazyload) classNames.push("lazyload");
|
11
|
+
$ const attrs = getAsObject(input.attrs);
|
12
|
+
$ if (input.width && input.width > 0 && !attrs.width && !attrs.height) {
|
13
|
+
attrs.width = input.width;
|
14
|
+
const height = input.height || imageHeight(input.width, input.ar) || undefined;
|
15
|
+
if (height) attrs.height = height;
|
16
|
+
};
|
10
17
|
|
11
18
|
<if(lazyload)>
|
12
19
|
<img
|
13
|
-
...
|
20
|
+
...attrs
|
14
21
|
src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
|
15
22
|
srcset=null
|
16
23
|
data-src=src
|
@@ -21,7 +28,7 @@ $ if (lazyload) classNames.push("lazyload");
|
|
21
28
|
</if>
|
22
29
|
<else>
|
23
30
|
<img
|
24
|
-
...
|
31
|
+
...attrs
|
25
32
|
src=src
|
26
33
|
srcset=srcset
|
27
34
|
class=classNames
|
@@ -63,7 +63,10 @@
|
|
63
63
|
},
|
64
64
|
"@class": "string",
|
65
65
|
"@attrs": "object",
|
66
|
-
"@link": "object"
|
66
|
+
"@link": "object",
|
67
|
+
"@width": "number",
|
68
|
+
"@height": "number",
|
69
|
+
"@ar": "string"
|
67
70
|
},
|
68
71
|
"<marko-web-link>": {
|
69
72
|
"template": "./link.marko",
|
@@ -175,7 +178,10 @@
|
|
175
178
|
},
|
176
179
|
"@class": "string",
|
177
180
|
"@attrs": "object",
|
178
|
-
"@link": "object"
|
181
|
+
"@link": "object",
|
182
|
+
"@width": "string",
|
183
|
+
"@height": "string",
|
184
|
+
"@ar": "string"
|
179
185
|
},
|
180
186
|
"<link>": {
|
181
187
|
"<before>": {},
|
@@ -195,7 +201,10 @@
|
|
195
201
|
"@srcset": {
|
196
202
|
"type": "array",
|
197
203
|
"required": true
|
198
|
-
}
|
204
|
+
},
|
205
|
+
"@width": "number",
|
206
|
+
"@height": "number",
|
207
|
+
"@ar": "string"
|
199
208
|
}
|
200
209
|
}
|
201
210
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { buildImgixUrl } from "@parameter1/base-cms-image";
|
2
2
|
import { get } from "@parameter1/base-cms-object-path";
|
3
|
+
import imageHeight from "./utils/image-height";
|
3
4
|
|
4
5
|
$ const element = "node__image";
|
5
6
|
$ const hasImage = Boolean(input.src);
|
@@ -14,6 +15,11 @@ $ const options = {
|
|
14
15
|
...input.options,
|
15
16
|
}
|
16
17
|
|
18
|
+
$ if (options.w) {
|
19
|
+
attrs.width = options.w;
|
20
|
+
attrs.height = options.h || (input.ar ? imageHeight(input.width, input.ar) : undefined);
|
21
|
+
}
|
22
|
+
|
17
23
|
<!-- @todo add modifiers -->
|
18
24
|
|
19
25
|
<if(hasImage)>
|
@@ -26,6 +32,8 @@ $ const options = {
|
|
26
32
|
attrs=attrs
|
27
33
|
class=[element, input.class]
|
28
34
|
lazyload=input.lazyload
|
35
|
+
width=input.width
|
36
|
+
height=input.height
|
29
37
|
/>
|
30
38
|
</if>
|
31
39
|
<else-if(input.usePlaceholder)>
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@parameter1/base-cms-marko-web",
|
3
|
-
"version": "3.7.
|
3
|
+
"version": "3.7.11",
|
4
4
|
"description": "Core Marko+Express components for BaseCMS websites",
|
5
5
|
"author": "Jacob Bare <jacob@parameter1.com>",
|
6
6
|
"main": "index.js",
|
@@ -46,5 +46,5 @@
|
|
46
46
|
"publishConfig": {
|
47
47
|
"access": "public"
|
48
48
|
},
|
49
|
-
"gitHead": "
|
49
|
+
"gitHead": "ab5824f00f04768be6729f66dfc62fa7b0b09c89"
|
50
50
|
}
|