39 $doc = $block->getDom();
40 $resultList = $doc->querySelectorAll($selector);
43 foreach ($data as $pos => $value)
45 if (isset($resultList[$pos]))
47 if (isset($value[
'src']) && $value[
'src'])
49 if ($resultList[$pos]->getTagName() ===
'IFRAME')
51 $resultList[$pos]->setAttribute(
'src', $value[
'src']);
55 $resultList[$pos]->setAttribute(
'data-src', $value[
'src']);
59 if (isset($value[
'source']) && $value[
'source'])
61 $resultList[$pos]->setAttribute(
'data-source', $value[
'source']);
66 isset($value[
'ratio'], $value[
'src'])
67 && $value[
'ratio'] && $value[
'src']
68 && $valueBefore[
'src'] !== $value[
'src']
69 && in_array($value[
'ratio'], self::RATIO_CLASSES)
72 $containerNode = $resultList[$pos]->getParentNode();
73 if ($containerNode && in_array(self::CONTAINER_CLASS, $containerNode->getClassList()))
75 $classes = $containerNode->getClassList();
76 $classes = array_diff($classes, self::RATIO_CLASSES);
77 $classes[] = $value[
'ratio'];
78 $containerNode->setClassList($classes);
84 foreach (StyleInliner::getStyle($resultList[$pos]) as $key => $stylesValue)
86 if ($key !==
'background' && $key !==
'background-image')
88 $styles[] =
"{$key}: {$stylesValue};";
91 if (isset($value[
'preview']) && $value[
'preview'])
93 $styles[] =
"background-image: url('{$value['preview']}');";
94 $resultList[$pos]->setAttribute(
'data-preview', $value[
'preview']);
98 $resultList[$pos]->removeAttribute(
'data-preview');
100 $styles = implode(
' ', $styles);
101 $resultList[$pos]->setAttribute(
'style', $styles);
107 $history->push(
'EDIT_EMBED', [
109 'selector' => $selector,
110 'position' => (
int)$pos,
111 'valueBefore' => $valueBefore[$pos],
112 'valueAfter' => $value,
127 $doc = $block->getDom();
128 $resultList = $doc->querySelectorAll($selector);
130 foreach ($resultList as $pos => $res)
133 $containerNode = $res->getParentNode();
134 if ($containerNode && in_array(self::CONTAINER_CLASS, $containerNode->getClassList()))
136 $ratio = array_intersect($containerNode->getCLassList(), self::RATIO_CLASSES);
137 $ratio = empty($ratio) ?
'' : array_shift($ratio);
141 'src' => $res->getAttribute(
'data-src') ?: $res->getAttribute(
'src'),
142 'source' => $res->getAttribute(
'data-source'),
143 'preview' => $res->getAttribute(
'data-preview'),