119 'right' => [1, 9, 17, 25],
120 'left' => [2, 10, 18, 26]
123 'above' => [0, 1, 2],
124 'intext' => [17, 18, 25, 26],
125 'below' => [8, 9, 10]
146 'columnSpacing' => 0,
236 array $contentObjectConfiguration,
241 return $processedData;
244 $this->contentObjectRenderer = $cObj;
248 'filesProcessedDataKey',
252 if (isset($processedData[$filesProcessedDataKey]) && is_array($processedData[$filesProcessedDataKey])) {
253 $this->fileObjects = $processedData[$filesProcessedDataKey];
254 $this->galleryData[
'count'][
'files'] = count($this->fileObjects);
287 return $processedData;
301 if ($dataArrayKey && isset($this->contentObjectRenderer->data[$dataArrayKey])) {
302 $defaultValue = $this->contentObjectRenderer->data[$dataArrayKey];
304 return $this->contentObjectRenderer->stdWrapValue(
306 $this->processorConfiguration,
319 foreach ($this->availableGalleryPositions as $positionDirectionKey => $positionDirectionValue) {
320 foreach ($positionDirectionValue as $positionKey => $positionArray) {
321 if (in_array($this->mediaOrientation, $positionArray,
true)) {
322 $this->galleryData[
'position'][$positionDirectionKey] = $positionKey;
327 if ($this->mediaOrientation === 25 || $this->mediaOrientation === 26) {
328 $this->galleryData[
'position'][
'noWrap'] =
true;
337 if ($this->galleryData[
'position'][
'vertical'] ===
'intext') {
351 $columns = max((
int)$this->numberOfColumns, 1);
354 if ($columns > $this->galleryData[
'count'][
'files']) {
355 $columns = $this->galleryData[
'count'][
'files'];
358 if ($columns === 0) {
363 $rows = ceil($this->galleryData[
'count'][
'files'] / $columns);
365 $this->galleryData[
'count'][
'columns'] = $columns;
366 $this->galleryData[
'count'][
'rows'] = (int)$rows;
379 $columnSpacingTotal = ($this->galleryData[
'count'][
'columns'] - 1) * $this->columnSpacing;
381 $galleryWidthMinusBorderAndSpacing = max($this->galleryData[
'width'] - $columnSpacingTotal, 1);
383 if ($this->borderEnabled) {
384 $borderPaddingTotal = ($this->galleryData[
'count'][
'columns'] * 2) * $this->borderPadding;
385 $borderWidthTotal = ($this->galleryData[
'count'][
'columns'] * 2) * $this->borderWidth;
386 $galleryWidthMinusBorderAndSpacing = $galleryWidthMinusBorderAndSpacing - $borderPaddingTotal - $borderWidthTotal;
390 if ($this->equalMediaHeight) {
391 $mediaScalingCorrection = 1;
392 $maximumRowWidth = 0;
395 for ($row = 1; $row <= $this->galleryData[
'count'][
'rows']; $row++) {
397 for ($column = 1; $column <= $this->galleryData[
'count'][
'columns']; $column++) {
398 $fileKey = (($row - 1) * $this->galleryData[
'count'][
'columns']) + $column - 1;
399 if ($fileKey > $this->galleryData[
'count'][
'files'] - 1) {
405 $maximumRowWidth = max($totalRowWidth, $maximumRowWidth);
406 $mediaInRowScaling = $totalRowWidth / $galleryWidthMinusBorderAndSpacing;
407 $mediaScalingCorrection = max($mediaInRowScaling, $mediaScalingCorrection);
411 foreach ($this->fileObjects as $key => $fileObject) {
412 $mediaHeight = floor($this->equalMediaHeight / $mediaScalingCorrection);
416 $this->mediaDimensions[$key] = [
417 'width' => $mediaWidth,
418 'height' => $mediaHeight
423 $this->galleryData[
'width'] = floor($maximumRowWidth / $mediaScalingCorrection);
426 } elseif ($this->equalMediaWidth) {
427 $mediaScalingCorrection = 1;
431 $mediaInRowScaling = $totalRowWidth / $galleryWidthMinusBorderAndSpacing;
432 $mediaScalingCorrection = max($mediaInRowScaling, $mediaScalingCorrection);
435 foreach ($this->fileObjects as $key => $fileObject) {
436 $mediaWidth = floor($this->equalMediaWidth / $mediaScalingCorrection);
437 $mediaHeight = floor(
440 $this->mediaDimensions[$key] = [
441 'width' => $mediaWidth,
442 'height' => $mediaHeight
447 $this->galleryData[
'width'] = floor($totalRowWidth / $mediaScalingCorrection);
451 $maxMediaWidth = (int)($galleryWidthMinusBorderAndSpacing / $this->galleryData[
'count'][
'columns']);
452 foreach ($this->fileObjects as $key => $fileObject) {
454 $mediaWidth = $croppedWidth > 0 ? min($maxMediaWidth, $croppedWidth) : $maxMediaWidth;
455 $mediaHeight = floor(
458 $this->mediaDimensions[$key] = [
459 'width' => $mediaWidth,
460 'height' => $mediaHeight
477 if (!$fileObject->hasProperty(
'crop') || empty($fileObject->getProperty(
'crop'))) {
478 return $fileObject->getProperty($dimensionalProperty);
481 $croppingConfiguration = $fileObject->getProperty(
'crop');
483 return (
int)$cropVariantCollection->getCropArea($this->cropVariant)->makeAbsoluteBasedOnFile($fileObject)->asArray()[$dimensionalProperty];
493 for ($row = 1; $row <= $this->galleryData[
'count'][
'rows']; $row++) {
494 for ($column = 1; $column <= $this->galleryData[
'count'][
'columns']; $column++) {
495 $fileKey = (($row - 1) * $this->galleryData[
'count'][
'columns']) + $column - 1;
497 $this->galleryData[
'rows'][$row][
'columns'][$column] = [
498 'media' => $this->fileObjects[$fileKey] ??
null,
500 'width' => $this->mediaDimensions[$fileKey][
'width'] ??
null,
501 'height' => $this->mediaDimensions[$fileKey][
'height'] ?? null