gatsby-core-theme 40.0.8 → 40.0.9

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## [40.0.9](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v40.0.8...v40.0.9) (2024-10-22)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * content images ([83fa09e](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/83fa09e6f23a53d4b8efe1d52f3c073ea4735490))
7
+ * images ([ff0c59e](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/ff0c59e88cbdb26c9cc1cde35b7a588c7520a814))
8
+
9
+
10
+ * Merge branch 'tm-4346-content-images' into 'master' ([dadb989](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/dadb989a7181c2e368c732dee2801ac9314bde8b))
11
+
1
12
  ## [40.0.8](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v40.0.7...v40.0.8) (2024-10-22)
2
13
 
3
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "40.0.8",
3
+ "version": "40.0.9",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "author": "",
6
6
  "license": "ISC",
@@ -26,20 +26,25 @@ const processImageNode = (node, moduleWidth = 960, loading) => {
26
26
  stylesClass = 'alignRight';
27
27
  }
28
28
 
29
- const imgWidthData = node?.attribs?.width?.replace('px', '')
30
- || node?.attribs?.['data-width']?.replace('px', '')
31
- || getValueFromStyle(node?.attribs?.style, 'width')
32
- || '';
33
-
34
- const imgWidth = parseFloat(imgWidthData) > moduleWidth ? moduleWidth : imgWidthData;
35
-
36
- const imgHeightData = node?.attribs?.height
37
- || node?.attribs?.['data-height']
38
- || getValueFromStyle(node?.attribs?.style, 'height')
39
- || '';
40
-
41
- const imgHeight = imgHeightData === 'auto' ? '298' : imgHeightData.replace('px', '')
42
-
29
+ const imgWidthData = node?.attribs?.width
30
+ || node?.attribs?.['data-width']
31
+ || getValueFromStyle(node?.attribs?.style, 'width')
32
+ || '';
33
+
34
+ const imgHeightData = node?.attribs?.height
35
+ || node?.attribs?.['data-height']
36
+ || getValueFromStyle(node?.attribs?.style, 'height')
37
+ || '';
38
+
39
+ // Parse the width and height as numbers
40
+ const originalWidth = parseFloat(imgWidthData);
41
+ const originalHeight = (imgHeightData === 'auto') ? 298 : parseFloat(imgHeightData);
42
+
43
+ // If width is greater than moduleWidth, adjust the width to moduleWidth and scale height accordingly
44
+ const imgWidth = originalWidth > moduleWidth ? moduleWidth : originalWidth || '';
45
+ const imgHeight = originalWidth > moduleWidth
46
+ ? Math.round((originalHeight / originalWidth) * moduleWidth)
47
+ : originalHeight || '';
43
48
 
44
49
  const lazyProps = {
45
50
  src: parseContentImageUrl(node.attribs.src, imgWidth, imgHeight),
@@ -23,8 +23,8 @@ describe('replaceMedia function', () => {
23
23
  expect(transformedNode.props.src).toBe(
24
24
  'https://cdn.images.com/fit-in/300x200/image.jpg'
25
25
  )
26
- expect(transformedNode.props.width).toBe('300')
27
- expect(transformedNode.props.height).toBe('200')
26
+ expect(transformedNode.props.width).toBe(300)
27
+ expect(transformedNode.props.height).toBe(200)
28
28
  expect(transformedNode.props.alt).toBe('Alt text')
29
29
  expect(transformedNode.props.className).toBe('alignCenter')
30
30
  })
@@ -116,7 +116,7 @@ describe('replaceMedia function', () => {
116
116
  'https://cdn.images.com/fit-in/100x50/1718708348/springbok-casino-bonus.jpg'
117
117
  )
118
118
  expect(imageNode.props.alt).toBe('Alt text')
119
- expect(imageNode.props.width).toBe('100')
120
- expect(imageNode.props.height).toBe('50')
119
+ expect(imageNode.props.width).toBe(100)
120
+ expect(imageNode.props.height).toBe(50)
121
121
  })
122
122
  })