37 protected function parse(): void
39 if (!$this->content || !$this->manifest[
'nodes'])
44 if ($this->skipDynamic && !empty($this->block->getDynamicParams()))
50 foreach ($this->manifest[
'nodes'] as $selector => $node)
52 if ($node[
'type'] ===
'img')
54 $node = Node\Img::changeNodeType($node, $this->block);
57 if ($node[
'type'] ===
'img' || $node[
'type'] ===
'styleimg')
59 $domElements = Node\Style::getNodesBySelector($this->block, $selector);
61 if ($node[
'type'] ===
'img')
63 foreach ($domElements as $domElement)
65 if ($domElement->getTagName() ===
'IMG')
71 $this->
parseBg($domElement, $selector);
76 elseif ($node[
'type'] ===
'styleimg')
78 foreach ($domElements as $domElement)
80 if ($domElement->getTagName() !==
'IMG')
92 $this->block->saveContent($this->block->getDom()->saveHTML());
139 $styles = DOM\StyleInliner::getStyle($node,
false);
140 if (!$styles[
'background-image'])
144 $origBg = implode(
'|', $styles[
'background-image']);
148 ($fileId = $node->getAttribute(
'data-fileid'))
153 $width = $fileArray[
'WIDTH'];
154 $height = $fileArray[
'HEIGHT'];
158 [$width, $height] = $manifestSize;
165 $node->setAttribute(
'data-lazy-bg',
'Y');
166 $node->setAttribute(
'data-bg', $origBg);
169 DOM\StyleInliner::setStyle($node, array_merge($styles, [
'background-image' => [
"url({$lazySrc})"]]));
170 if ($origSrc = self::getSrcByBgStyle($origBg))
172 if (isset($origSrc[
'src']))
174 $node->setAttribute(
'data-src', $origSrc[
'src']);
176 if (isset($origSrc[
'src2x']))
178 $node->setAttribute(
'data-src2x', $origSrc[
'src2x']);