@ecency/render-helper 2.2.32 → 2.2.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecency/render-helper",
3
- "version": "2.2.32",
3
+ "version": "2.2.33",
4
4
  "description": "Markdown+Html Render helper",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -131,4 +131,14 @@ describe('catchPostImage', () => {
131
131
  }
132
132
  expect(catchPostImage(input as any)).toBe('')
133
133
  })
134
+
135
+ it('11- Image field is string', () => {
136
+ const input = {
137
+ 'json_metadata': {
138
+ 'image': 'https://files.peakd.com/file/peakd-hive/aggroed/agtirkG8-image.png'
139
+ }
140
+ }
141
+ const expected = 'https://images.ecency.com/p/hgjbks2vRxvf3xsYr6qQ7dm31DuBHGui8pKMdEVPxhLfEeEoVMPfUw4Z6QduNMpLay65R9vadbefhmDKmhM6HD8w8a.png?format=match&mode=fit'
142
+ expect(catchPostImage(input as any)).toBe(expected)
143
+ })
134
144
  })
@@ -26,6 +26,13 @@ function getImage(entry: Entry, width = 0, height = 0, format = 'match'): string
26
26
  }
27
27
  }
28
28
 
29
+ if (meta && typeof meta.image === 'string' && meta.image.length > 0) {
30
+ if (isGifLink(meta.image)) {
31
+ return proxifyImageSrc(meta.image, 0, 0, format)
32
+ }
33
+ return proxifyImageSrc(meta.image, width, height, format)
34
+ }
35
+
29
36
  if (meta && meta.image && !!meta.image.length && meta.image[0]) {
30
37
  if (isGifLink(meta.image[0])) {
31
38
  return proxifyImageSrc(meta.image[0], 0, 0, format)