@ecency/render-helper 2.4.11 → 2.4.12

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.
@@ -1493,11 +1493,23 @@ function getImage(entry, width = 0, height = 0, format = "match") {
1493
1493
  }
1494
1494
  function catchPostImage(obj, width = 0, height = 0, format = "match") {
1495
1495
  if (typeof obj === "string") {
1496
- const entryWrapper = {
1497
- body: obj,
1498
- json_metadata: "{}"
1499
- };
1500
- return getImage(entryWrapper, width, height, format);
1496
+ const html = markdown2Html(obj);
1497
+ const doc = createDoc(html);
1498
+ if (!doc) {
1499
+ return null;
1500
+ }
1501
+ const imgEls = doc.getElementsByTagName("img");
1502
+ if (imgEls.length >= 1) {
1503
+ const src = imgEls[0].getAttribute("src");
1504
+ if (!src) {
1505
+ return null;
1506
+ }
1507
+ if (isGifLink(src)) {
1508
+ return proxifyImageSrc(src, 0, 0, format);
1509
+ }
1510
+ return proxifyImageSrc(src, width, height, format);
1511
+ }
1512
+ return null;
1501
1513
  }
1502
1514
  const key = `${makeEntryCacheKey(obj)}-${width}x${height}-${format}`;
1503
1515
  const item = cacheGet(key);