PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.14.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.14.0
2.14.0 2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 81 releases
← All changes | includes/import/image-parsers/ablocks/image-comparison-parser.php +27 -0 2.7.4 → 2.14.0 View file →
@@ -1,0 +1,27 @@
1 +<?php
2 +
3 +namespace ABlocks\import\ImageParsers\ablocks;
4 +
5 +use ABlocks\import\ImageParsers\AbstractImageParser;
6 +use DOMDocument;
7 +
8 +class ImageComparisonParser extends AbstractImageParser {
9 +
10 + protected function parse() {
11 + $dom = new DOMDocument();
12 + $dom->loadHTML( $this->block['innerHTML'], LIBXML_NOERROR | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD );
13 +
14 + $before_parsed_img = $this->parse_img_tag( $dom, 0 );
15 + $after_parsed_img = $this->parse_img_tag( $dom, 1 );
16 + if ( ! $before_parsed_img || ! $after_parsed_img ) {
17 + return;
18 + }
19 + list( , $before_attachment_url, $before_image_url ) = $before_parsed_img;
20 + list( , $after_attachment_url, $after_image_url ) = $after_parsed_img;
21 +
22 + $this->block['attrs']['beforeImage'] = $before_attachment_url;
23 + $this->block['attrs']['afterImage'] = $after_attachment_url;
24 + $this->block['innerHTML'] = str_replace( [ $before_image_url, $after_image_url ], [ $before_attachment_url, $after_attachment_url ], $this->block['innerHTML'] );
25 + $this->block['innerContent'] = array_map( fn( $content) => str_replace( [ $before_image_url, $after_image_url ], [ $before_attachment_url, $after_attachment_url ], $content ), $this->block['innerContent'] );
26 + }
27 +}