@ecency/render-helper 2.5.12 → 2.5.13

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.
@@ -1242,14 +1242,15 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
1242
1242
  el.setAttribute("data-start-time", startTime);
1243
1243
  }
1244
1244
  if (renderOptions?.embedVideosDirectly) {
1245
+ const directSrc = `https://www.youtube.com/embed/${vid}`;
1245
1246
  const wrapper = el.ownerDocument.createElement("span");
1246
1247
  wrapper.setAttribute("class", "er-youtube-frame");
1247
1248
  wrapper.setAttribute("style", "display:block");
1248
1249
  const iframe2 = el.ownerDocument.createElement("iframe");
1249
1250
  iframe2.setAttribute("class", "youtube-player");
1250
- iframe2.setAttribute("src", embedSrc);
1251
+ iframe2.setAttribute("src", directSrc);
1251
1252
  iframe2.setAttribute("title", "YouTube video");
1252
- iframe2.setAttribute("allow", "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture; web-share");
1253
+ iframe2.setAttribute("allow", "accelerometer; encrypted-media; gyroscope; picture-in-picture; web-share");
1253
1254
  iframe2.setAttribute("allowfullscreen", "");
1254
1255
  wrapper.appendChild(iframe2);
1255
1256
  el.appendChild(wrapper);
@@ -1386,12 +1387,13 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
1386
1387
  el.textContent = "";
1387
1388
  }
1388
1389
  if (renderOptions?.embedVideosDirectly) {
1390
+ const directSrc = `${videoHref}&autoplay=false`;
1389
1391
  const wrapper = el.ownerDocument.createElement("span");
1390
1392
  wrapper.setAttribute("class", "er-speak-frame");
1391
1393
  wrapper.setAttribute("style", "display:block");
1392
1394
  const iframe2 = el.ownerDocument.createElement("iframe");
1393
1395
  iframe2.setAttribute("class", "speak-iframe");
1394
- iframe2.setAttribute("src", videoHref);
1396
+ iframe2.setAttribute("src", directSrc);
1395
1397
  iframe2.setAttribute("title", "3Speak video");
1396
1398
  iframe2.setAttribute("allow", "accelerometer; encrypted-media; gyroscope; picture-in-picture; web-share");
1397
1399
  iframe2.setAttribute("allowfullscreen", "");
@@ -1504,7 +1506,7 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
1504
1506
  }
1505
1507
 
1506
1508
  // src/methods/iframe.method.ts
1507
- function iframe(el, parentDomain = "ecency.com", forApp = false) {
1509
+ function iframe(el, parentDomain = "ecency.com", forApp = false, renderOptions) {
1508
1510
  if (!el || !el.parentNode) {
1509
1511
  return;
1510
1512
  }
@@ -1547,7 +1549,12 @@ function iframe(el, parentDomain = "ecency.com", forApp = false) {
1547
1549
  normalizedSrc = `${normalizedSrc}&mode=iframe`;
1548
1550
  }
1549
1551
  const hasAutoplay = /[?&]autoplay=/.test(normalizedSrc);
1550
- let s = hasAutoplay ? normalizedSrc : `${normalizedSrc}&autoplay=true`;
1552
+ let s;
1553
+ if (renderOptions?.embedVideosDirectly) {
1554
+ s = hasAutoplay ? normalizedSrc.replace(/([?&]autoplay=)[^&]*/i, "$1false") : `${normalizedSrc}&autoplay=false`;
1555
+ } else {
1556
+ s = hasAutoplay ? normalizedSrc : `${normalizedSrc}&autoplay=true`;
1557
+ }
1551
1558
  if (forApp && !/[?&]layout=/.test(s)) {
1552
1559
  s = `${s}&layout=mobile`;
1553
1560
  }
@@ -1861,7 +1868,7 @@ function traverse(node, forApp, depth = 0, state = { firstImageFound: false }, p
1861
1868
  a(child, forApp, parentDomain, seoContext, renderOptions);
1862
1869
  }
1863
1870
  if (child.nodeName.toLowerCase() === "iframe") {
1864
- iframe(child, parentDomain, forApp);
1871
+ iframe(child, parentDomain, forApp, renderOptions);
1865
1872
  }
1866
1873
  if (child.nodeName === "#text") {
1867
1874
  text(child, forApp);