@jay-framework/wix-media 0.19.6 → 0.19.7

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.
@@ -28,11 +28,28 @@ URL format: `https://static.wixstatic.com/media/{mediaId}/v1/{mode}/{params}/fil
28
28
  - **crop** — extract a rectangle at specific coordinates
29
29
  `<img src="https://static.wixstatic.com/media/{mediaId}/v1/crop/x_100,y_50,w_800,h_600/file.jpg" alt="" />`
30
30
 
31
+ #### Crop + Resize (chained transforms)
32
+
33
+ Add a `/crop/` segment before `/fill/` (or `/fit/`) to first extract a region, then resize it:
34
+
35
+ ```
36
+ /v1/crop/x_{x},y_{y},w_{cropW},h_{cropH}/fill/w_{outputW},h_{outputH}/file.ext
37
+ ```
38
+
39
+ Example — crop a 2688×1278 region starting at (0, 514), then fill-resize to 1437×683:
40
+
41
+ ```html
42
+ <img src="https://static.wixstatic.com/media/{mediaId}/v1/crop/x_0,y_514,w_2688,h_1278/fill/w_1437,h_683/file.jpg" alt="" />
43
+ ```
44
+
45
+ The crop coordinates refer to the original image pixels. The fill/fit parameters set the final output size.
46
+
31
47
  #### Parameters
32
48
 
33
49
  - `w_{width}` — target width (1–5000 px)
34
50
  - `h_{height}` — target height (1–5000 px)
35
51
  - `x_{x},y_{y}` — crop start position (crop mode only)
52
+ - `w_{width},h_{height}` — crop region size (crop mode / chained crop)
36
53
  - `q_{quality}` — JPEG quality (1–100)
37
54
 
38
55
  #### Output format (set via file extension)
package/dist/index.js CHANGED
@@ -12,6 +12,8 @@ const WIXSTATIC_MEDIA_RE = /static\.wixstatic\.com\/media\//;
12
12
  const V1_TRANSFORM_RE = /\/v1\//;
13
13
  const IMAGE_EXTENSIONS_RE = /\.(jpe?g|png|gif|webp|svg|bmp|ico)$/i;
14
14
  const SRCSET_UNENCODED_COMMA_RE = /\/v1\/[^/]+\/[^/]*[a-z]_\d+,[a-z]_\d+/;
15
+ const WIDTH_PARAM_RE = /w_(\d+)/;
16
+ const SRCSET_MIN_WIDTH_THRESHOLD = 400;
15
17
  const MEDIA_SRC_ATTRS = ["src", "poster"];
16
18
  const MEDIA_SRCSET_ATTRS = ["srcset"];
17
19
  const MEDIA_ELEMENTS = /* @__PURE__ */ new Set(["img", "video", "source"]);
@@ -80,6 +82,24 @@ const validate = (ctx) => {
80
82
  }
81
83
  }
82
84
  }
85
+ if (tagName === "img" && !el.getAttribute("srcset")) {
86
+ const srcValue = el.getAttribute("src");
87
+ if (srcValue) {
88
+ const srcParts = parseTemplateParts(srcValue);
89
+ const staticText = srcParts.filter((p) => p.kind === "static").map((p) => p.value).join("");
90
+ if (V1_TRANSFORM_RE.test(staticText)) {
91
+ const widthMatch = staticText.match(WIDTH_PARAM_RE);
92
+ if (widthMatch && parseInt(widthMatch[1], 10) >= SRCSET_MIN_WIDTH_THRESHOLD) {
93
+ findings.push({
94
+ severity: "warning",
95
+ message: "This image is ≥400px wide but has no srcset attribute. Add srcset with sizes for common breakpoints to serve appropriately sized images across devices. See agent-kit/wix-media.md for the responsive image pattern.",
96
+ element: "<img>",
97
+ attribute: "src"
98
+ });
99
+ }
100
+ }
101
+ }
102
+ }
83
103
  for (const attr of MEDIA_SRCSET_ATTRS) {
84
104
  const value = el.getAttribute(attr);
85
105
  if (!value) continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/wix-media",
3
- "version": "0.19.6",
3
+ "version": "0.19.7",
4
4
  "type": "module",
5
5
  "description": "Wix Media Manager plugin for Jay Framework — media validation, index generation, and agent-kit references",
6
6
  "license": "Apache-2.0",
@@ -25,19 +25,19 @@
25
25
  "test": "vitest run"
26
26
  },
27
27
  "dependencies": {
28
- "@jay-framework/compiler-jay-html": "^0.19.6",
29
- "@jay-framework/compiler-shared": "^0.19.6",
30
- "@jay-framework/component": "^0.19.6",
31
- "@jay-framework/fullstack-component": "^0.19.6",
32
- "@jay-framework/stack-server-runtime": "^0.19.6",
33
- "@jay-framework/wix-server-client": "^0.19.6",
34
- "@jay-framework/wix-utils": "^0.19.6",
28
+ "@jay-framework/compiler-jay-html": "^0.19.7",
29
+ "@jay-framework/compiler-shared": "^0.19.7",
30
+ "@jay-framework/component": "^0.19.7",
31
+ "@jay-framework/fullstack-component": "^0.19.7",
32
+ "@jay-framework/stack-server-runtime": "^0.19.7",
33
+ "@jay-framework/wix-server-client": "^0.19.7",
34
+ "@jay-framework/wix-utils": "^0.19.7",
35
35
  "@wix/media": "^1.0.247",
36
36
  "@wix/sdk": "^1.21.5"
37
37
  },
38
38
  "devDependencies": {
39
- "@jay-framework/compiler-jay-stack": "^0.19.6",
40
- "@jay-framework/vite-plugin": "^0.19.6",
39
+ "@jay-framework/compiler-jay-stack": "^0.19.7",
40
+ "@jay-framework/vite-plugin": "^0.19.7",
41
41
  "@types/node": "^20.11.0",
42
42
  "node-html-parser": "^6.1.0",
43
43
  "rimraf": "^5.0.5",