File tree Expand file tree Collapse file tree 2 files changed +67
-0
lines changed
Plugin/Magento/PageBuilder/Model/Filter Expand file tree Collapse file tree 2 files changed +67
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Copyright © Magefan ([email protected] ). All rights reserved. 4+ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
5+ *
6+ * Glory to Ukraine! Glory to the heroes!
7+ */
8+
9+ declare (strict_types = 1 );
10+
11+ namespace Magefan \LazyLoad \Plugin \Magento \PageBuilder \Model \Filter ;
12+
13+ use Magefan \LazyLoad \Model \Config ;
14+
15+ class Template
16+ {
17+ /**
18+ * @var Config
19+ */
20+ private $ config ;
21+
22+ /**
23+ * @param Config $config
24+ */
25+ public function __construct (
26+ Config $ config
27+ ) {
28+ $ this ->config = $ config ;
29+ }
30+
31+ /**
32+ * @param $subject
33+ * @param $result
34+ * @return mixed|string
35+ */
36+ public function afterFilter ($ subject , $ result )
37+ {
38+ if ($ this ->config ->getEnabled ()) {
39+ $ this ->moveMfDislazyAttributeDirectAfterImg ($ result );
40+ }
41+
42+ return $ result ;
43+ }
44+
45+ /**
46+ * @param string $result
47+ * @return void
48+ */
49+ private function moveMfDislazyAttributeDirectAfterImg (string &$ result )
50+ {
51+ if (strpos ($ result , 'mfdislazy="1" ' ) !== false ) {
52+ $ result = explode ('<img ' , $ result );
53+
54+ foreach ($ result as $ key => $ imgStart ) {
55+ if (strpos ($ imgStart , 'mfdislazy="1" ' ) !== false ) {
56+ $ result [$ key ] = 'mfdislazy="1" ' . str_replace ('mfdislazy="1" ' , '' , $ imgStart );
57+ }
58+ }
59+
60+ $ result = implode ('<img ' , $ result );
61+ }
62+ }
63+ }
Original file line number Diff line number Diff line change 4747 </argument >
4848 </arguments >
4949 </type >
50+
51+ <type name =" Magento\PageBuilder\Model\Filter\Template" >
52+ <plugin disabled =" false" name =" move-mfdislazy-direct-after-img" sortOrder =" 10" type =" Magefan\LazyLoad\Plugin\Magento\PageBuilder\Model\Filter\Template" />
53+ </type >
5054</config >
You can’t perform that action at this time.
0 commit comments