Skip to content

Commit

Permalink
[BUGFIX] Fix handling of METS files without physical structure
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Jan 5, 2025
1 parent ef2cc30 commit cfd701f
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions Classes/Common/MetsDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,16 +435,18 @@ private function getThumbnail(string $id = '')

$thumbnail = null;

while ($fileGrpThumb = array_shift($fileGrpsThumb)) {
if (empty($id)) {
$thumbnail = $this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb] ?? null;
} else {
$parentId = $this->smLinks['l2p'][$id][0] ?? null;
$thumbnail = $this->physicalStructureInfo[$parentId]['files'][$fileGrpThumb] ?? null;
}
if (!empty($this->physicalStructure)) {
while ($fileGrpThumb = array_shift($fileGrpsThumb)) {
if (empty($id)) {
$thumbnail = $this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb] ?? null;
} else {
$parentId = $this->smLinks['l2p'][$id][0] ?? null;
$thumbnail = $this->physicalStructureInfo[$parentId]['files'][$fileGrpThumb] ?? null;
}

if (!empty($thumbnail)) {
break;
if (!empty($thumbnail)) {
break;
}
}
}
return $thumbnail;
Expand Down Expand Up @@ -1416,7 +1418,10 @@ protected function magicGetThumbnail(bool $forceReload = false): string
) {
$this->thumbnail = $this->getFileLocation($this->physicalStructureInfo[$this->smLinks['l2p'][$strctId][0]]['files'][$fileGrpThumb]);
break;
} elseif (!empty($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb])) {
} elseif (
!empty($this->physicalStructure)
&& !empty($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb])
) {
$this->thumbnail = $this->getFileLocation($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb]);
break;
}
Expand Down

0 comments on commit cfd701f

Please sign in to comment.