diff --git a/module/Finna/src/Finna/RecordDriver/SolrLido.php b/module/Finna/src/Finna/RecordDriver/SolrLido.php index cf6fbb107eb..bebd5458081 100644 --- a/module/Finna/src/Finna/RecordDriver/SolrLido.php +++ b/module/Finna/src/Finna/RecordDriver/SolrLido.php @@ -639,7 +639,14 @@ protected function getRepresentations(string $language): array // Representation is a 3d model if (in_array($type, $modelTypeKeys)) { - if ($model = $this->getModel($url, $format, $type)) { + if ( + $model = $this->getModel( + $url, + $format, + $type, + $representation->resourceMeasurementsSet + ) + ) { $modelUrls[] = $model; } continue; @@ -829,9 +836,10 @@ protected function getExtraDetails( * - type Model type preview_3d or provided_3d as key * url to model as value * - * @param string $url Model url - * @param string $format Model format - * @param string $type Model type + * @param string $url Model url + * @param string $format Model format + * @param string $type Model type + * @param \SimpleXmlElement $measurements Measurements SimpleXmlElement * * @return array */ @@ -839,6 +847,7 @@ protected function getModel( string $url, string $format, string $type, + \SimpleXmlElement $measurements = null, ): array { $type = $this->modelTypes[$type]; $format = strtolower($format); @@ -849,6 +858,9 @@ protected function getModel( 'url' => $url, 'format' => $format, 'type' => $type, + 'data' => $this->formatResourceMeasurements( + $measurements + ), ]; } diff --git a/module/Finna/tests/fixtures/lido/lido_test.xml b/module/Finna/tests/fixtures/lido/lido_test.xml index 949ffa8281c..460321498c3 100644 --- a/module/Finna/tests/fixtures/lido/lido_test.xml +++ b/module/Finna/tests/fixtures/lido/lido_test.xml @@ -359,6 +359,13 @@ https://gltfmalli.gltf + + koko + size + tavua + bytes + 60840000 + https://glbmalli.glb diff --git a/module/Finna/tests/unit-tests/src/FinnaTest/RecordDriver/SolrLidoTest.php b/module/Finna/tests/unit-tests/src/FinnaTest/RecordDriver/SolrLidoTest.php index 809938edbcf..9601f57e4d7 100644 --- a/module/Finna/tests/unit-tests/src/FinnaTest/RecordDriver/SolrLidoTest.php +++ b/module/Finna/tests/unit-tests/src/FinnaTest/RecordDriver/SolrLidoTest.php @@ -63,11 +63,18 @@ public static function getRepresentationsData(): array 'url' => 'https://gltfmalli.gltf', 'format' => 'gltf', 'type' => 'preview', + 'data' => [ + 'size' => [ + 'unit' => 'byte', + 'value' => '60840000', + ], + ], ], [ 'url' => 'https://glbmalli.glb', 'format' => 'glb', 'type' => 'preview', + 'data' => [], ], ], 'rights' => [ diff --git a/themes/finna2/scss/finna/record.scss b/themes/finna2/scss/finna/record.scss index 2382db613da..f7a29dfb31b 100644 --- a/themes/finna2/scss/finna/record.scss +++ b/themes/finna2/scss/finna/record.scss @@ -213,6 +213,9 @@ a.authority { font-weight: 600; text-transform: uppercase; } + .dropdown-menu li .file-size { + font-size: $font-size-small; + } } .image-link { @@ -498,7 +501,7 @@ a.authority { } } -.open-link, .save-record-link, .record-link { +.open-link, .save-record-link, .record-link, .model-link .download-link { text-align: left; margin-top: 5px; color: $action-link-color; diff --git a/themes/finna2/templates/RecordDriver/DefaultRecord/model-download.phtml b/themes/finna2/templates/RecordDriver/DefaultRecord/model-download.phtml index a65a9fbc150..af257659cb4 100644 --- a/themes/finna2/templates/RecordDriver/DefaultRecord/model-download.phtml +++ b/themes/finna2/templates/RecordDriver/DefaultRecord/model-download.phtml @@ -22,10 +22,13 @@ ], ] ) : $this->escapeHtmlAttr($model['url']); + if ($fileSize = $model['data']['size'] ?? '') { + $fileSize = !empty($fileSize['value']) && $fileSize['unit'] === 'byte' ? '(' . $this->fileSize(preg_replace('/[^0-9]/', '', $fileSize['value'])) . ')' : ''; + } ?> transEscWithPrefix('model_type_', $model['type'])?> - transEscWithPrefix('model_format_', $model['format'])?> + transEscWithPrefix('model_format_', $model['format'])?> @@ -48,11 +51,14 @@ ], ] ) : $this->escapeHtmlAttr($model['url']); + if ($fileSize = $model['data']['size'] ?? '') { + $fileSize = !empty($fileSize['value']) && $fileSize['unit'] === 'byte' ? '(' . $this->fileSize(preg_replace('/[^0-9]/', '', $fileSize['value'])) . ')' : ''; + } ?> icon('download') ?> transEsc('Download the file')?> - +