@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.
@@ -1522,11 +1522,23 @@ function getImage(entry, width = 0, height = 0, format = "match") {
1522
1522
  }
1523
1523
  function catchPostImage(obj, width = 0, height = 0, format = "match") {
1524
1524
  if (typeof obj === "string") {
1525
- const entryWrapper = {
1526
- body: obj,
1527
- json_metadata: "{}"
1528
- };
1529
- return getImage(entryWrapper, width, height, format);
1525
+ const html = markdown2Html(obj);
1526
+ const doc = createDoc(html);
1527
+ if (!doc) {
1528
+ return null;
1529
+ }
1530
+ const imgEls = doc.getElementsByTagName("img");
1531
+ if (imgEls.length >= 1) {
1532
+ const src = imgEls[0].getAttribute("src");
1533
+ if (!src) {
1534
+ return null;
1535
+ }
1536
+ if (isGifLink(src)) {
1537
+ return proxifyImageSrc(src, 0, 0, format);
1538
+ }
1539
+ return proxifyImageSrc(src, width, height, format);
1540
+ }
1541
+ return null;
1530
1542
  }
1531
1543
  const key = `${makeEntryCacheKey(obj)}-${width}x${height}-${format}`;
1532
1544
  const item = cacheGet(key);