@@ -186,58 +186,6 @@ private function parseParagraph($block)
186
186
$ this ->dom ->appendChild ($ node );
187
187
}
188
188
189
- private function parseLink ($ block )
190
- {
191
- $ link = $ this ->dom ->createElement ('a ' );
192
-
193
- $ link ->setAttribute ('href ' , $ block ->data ->link );
194
- $ link ->setAttribute ('target ' , '_blank ' );
195
- $ link ->setAttribute ('class ' , "{$ this ->prefix }-link " );
196
-
197
- $ innerContainer = $ this ->dom ->createElement ('div ' );
198
- $ innerContainer ->setAttribute ('class ' , "{$ this ->prefix }-link-container " );
199
-
200
- $ hasTitle = isset ($ block ->data ->meta ->title );
201
- $ hasDescription = isset ($ block ->data ->meta ->description );
202
- $ hasImage = isset ($ block ->data ->meta ->image );
203
-
204
- if ($ hasTitle ) {
205
- $ titleNode = $ this ->dom ->createElement ('div ' );
206
- $ titleNode ->setAttribute ('class ' , "{$ this ->prefix }-link-title " );
207
- $ titleText = new DOMText ($ block ->data ->meta ->title );
208
- $ titleNode ->appendChild ($ titleText );
209
- $ innerContainer ->appendChild ($ titleNode );
210
- }
211
-
212
- if ($ hasDescription ) {
213
- $ descriptionNode = $ this ->dom ->createElement ('div ' );
214
- $ descriptionNode ->setAttribute ('class ' , "{$ this ->prefix }-link-description " );
215
- $ descriptionText = new DOMText ($ block ->data ->meta ->description );
216
- $ descriptionNode ->appendChild ($ descriptionText );
217
- $ innerContainer ->appendChild ($ descriptionNode );
218
- }
219
-
220
- $ linkContainer = $ this ->dom ->createElement ('div ' );
221
- $ linkContainer ->setAttribute ('class ' , "{$ this ->prefix }-link-url " );
222
- $ linkText = new DOMText ($ block ->data ->link );
223
- $ linkContainer ->appendChild ($ linkText );
224
- $ innerContainer ->appendChild ($ linkContainer );
225
-
226
- $ link ->appendChild ($ innerContainer );
227
-
228
- if ($ hasImage ) {
229
- $ imageContainer = $ this ->dom ->createElement ('div ' );
230
- $ imageContainer ->setAttribute ('class ' , "{$ this ->prefix }-link-img-container " );
231
- $ image = $ this ->dom ->createElement ('img ' );
232
- $ image ->setAttribute ('src ' , $ block ->data ->meta ->image ->url );
233
- $ imageContainer ->appendChild ($ image );
234
- $ link ->appendChild ($ imageContainer );
235
- $ innerContainer ->setAttribute ('class ' , "{$ this ->prefix }-link-container-with-img " );
236
- }
237
-
238
- $ this ->dom ->appendChild ($ link );
239
- }
240
-
241
189
private function parseEmbed ($ block )
242
190
{
243
191
$ figure = $ this ->dom ->createElement ('figure ' );
@@ -392,6 +340,7 @@ private function parseImage($block)
392
340
$ img = $ this ->dom ->createElement ('img ' );
393
341
394
342
$ img ->setAttribute ('src ' , $ block ->data ->url );
343
+ $ img ->setAttribute ('alt ' , '' );
395
344
396
345
$ figure ->appendChild ($ img );
397
346
@@ -423,6 +372,7 @@ private function parseStandardImage($block)
423
372
$ img = $ this ->dom ->createElement ('img ' );
424
373
425
374
$ img ->setAttribute ('src ' , $ block ->data ->url );
375
+ $ img ->setAttribute ('alt ' , '' );
426
376
427
377
$ figure ->appendChild ($ img );
428
378
@@ -506,11 +456,15 @@ private function parseLinkTool($block)
506
456
$ figure = $ this ->dom ->createElement ('figure ' );
507
457
$ figure ->setAttribute ('class ' , $ this ->addClass ($ block ->type ));
508
458
459
+ $ site_name = !empty ($ block ->data ->meta ->site_name ) ? $ block ->data ->meta ->site_name : parse_url ($ block ->data ->link , PHP_URL_HOST );
460
+
509
461
$ link = $ this ->dom ->createElement ('a ' );
510
462
$ link ->setAttribute ('href ' , $ block ->data ->link );
463
+ $ link ->setAttribute ('target ' , '_blank ' );
511
464
512
465
$ img = $ this ->dom ->createElement ('img ' );
513
466
$ img ->setAttribute ('src ' , $ block ->data ->meta ->image ->url );
467
+ $ img ->setAttribute ('alt ' , '' );
514
468
515
469
$ link ->appendChild ($ img );
516
470
@@ -524,6 +478,11 @@ private function parseLinkTool($block)
524
478
$ link_description ->appendChild ($ this ->html5 ->loadHTMLFragment ($ block ->data ->meta ->description ));
525
479
$ link ->appendChild ($ link_description );
526
480
481
+ $ link_name = $ this ->dom ->createElement ('p ' );
482
+ $ link_name ->setAttribute ('class ' , "{$ this ->prefix }_sitename " );
483
+ $ link_name ->appendChild ($ this ->html5 ->loadHTMLFragment ($ site_name ));
484
+ $ link ->appendChild ($ link_name );
485
+
527
486
$ figure ->appendChild ($ link );
528
487
529
488
$ this ->dom ->appendChild ($ figure );
0 commit comments