@@ -26,6 +26,16 @@ public function parseBlock(HTML5 $html5, DOMDocument $document, object $block, s
2626 $ hasDescription = isset ($ block ->data ->meta ->description );
2727 $ hasImage = isset ($ block ->data ->meta ->image );
2828
29+ if ($ hasImage ) {
30+ $ imageContainer = $ document ->createElement ('div ' );
31+ $ imageContainer ->setAttribute ('class ' , "{$ prefix }-link-img-container " );
32+ $ image = $ document ->createElement ('img ' );
33+ $ image ->setAttribute ('src ' , $ block ->data ->meta ->image ->url );
34+ $ imageContainer ->appendChild ($ image );
35+ $ innerContainer ->appendChild ($ imageContainer );
36+ $ innerContainer ->setAttribute ('class ' , "{$ prefix }-link-container-with-img " );
37+ }
38+
2939 if ($ hasTitle ) {
3040 $ titleNode = $ document ->createElement ('div ' );
3141 $ titleNode ->setAttribute ('class ' , "{$ prefix }-link-title " );
@@ -35,7 +45,7 @@ public function parseBlock(HTML5 $html5, DOMDocument $document, object $block, s
3545 }
3646
3747 if ($ hasDescription ) {
38- $ descriptionNode = $ document ->createElement ('div ' );
48+ $ descriptionNode = $ document ->createElement ('p ' );
3949 $ descriptionNode ->setAttribute ('class ' , "{$ prefix }-link-description " );
4050 $ descriptionText = new DOMText ($ block ->data ->meta ->description );
4151 $ descriptionNode ->appendChild ($ descriptionText );
@@ -50,16 +60,6 @@ public function parseBlock(HTML5 $html5, DOMDocument $document, object $block, s
5060
5161 $ link ->appendChild ($ innerContainer );
5262
53- if ($ hasImage ) {
54- $ imageContainer = $ document ->createElement ('div ' );
55- $ imageContainer ->setAttribute ('class ' , "{$ prefix }-link-img-container " );
56- $ image = $ document ->createElement ('img ' );
57- $ image ->setAttribute ('src ' , $ block ->data ->meta ->image ->url );
58- $ imageContainer ->appendChild ($ image );
59- $ link ->appendChild ($ imageContainer );
60- $ innerContainer ->setAttribute ('class ' , "{$ prefix }-link-container-with-img " );
61- }
62-
6363 return $ link ;
6464 }
6565}
0 commit comments