From 00b50566aa66d7531e1d980626528f5b7f0b6dfd Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 2 Dec 2021 03:39:43 -0500 Subject: [PATCH] Display images when group layout is horizontal Remove the restriction to only show data nodes in a horizontal layout. Instead have it special case headers only, and then generically attempt to use a pre-rendered 'value' that data nodes have or ask for the node to be rendered to be displayed. Should handle issue #48 --- .../services/PortableInfoboxRenderService.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/includes/services/PortableInfoboxRenderService.php b/includes/services/PortableInfoboxRenderService.php index dacaa04..269612f 100644 --- a/includes/services/PortableInfoboxRenderService.php +++ b/includes/services/PortableInfoboxRenderService.php @@ -266,21 +266,22 @@ private function createHorizontalGroupData( array $groupData ) { foreach ( $groupData as $item ) { $data = $item['data']; + $type = $item['type']; - if ( $item['type'] === 'data' ) { + if ( $type === 'header' ) { + $horizontalGroupData['header'] = $data['value']; + $horizontalGroupData['inlineStyles'] = $this->inlineStyles; + }else{ $horizontalGroupData['data'][] = [ 'label' => $data['label'], - 'value' => $data['value'], - 'source' => $item['data']['source'] ?? "", - 'item-name' => $item['data']['item-name'] + 'value' => $data['value'] ?? $this->renderItem($type,$data), + 'source' => $data['source'] ?? "", + 'item-name' => $data['item-name'] ]; if ( !empty( $data['label'] ) ) { $horizontalGroupData['renderLabels'] = true; } - } elseif ( $item['type'] === 'header' ) { - $horizontalGroupData['header'] = $data['value']; - $horizontalGroupData['inlineStyles'] = $this->inlineStyles; } }