Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add image contract to segment cards in lists. #671

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion source/php/Module/ManualInput/ManualInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

use Municipio\Helper\Image as ImageHelper;

use Modularity\Integrations\Component\ImageResolver;
use Modularity\Integrations\Component\ImageFocusResolver;
use ComponentLibrary\Integrations\Image\Image as ImageComponentContract;

class ManualInput extends \Modularity\Module
{
public $slug = 'manualinput';
Expand Down Expand Up @@ -48,7 +52,7 @@ public function data(): array
});
$arr = array_merge($this->getManualInputDefaultValues(), $input);
$arr['isHighlighted'] = $this->canBeHighlighted($fields, $index);
$arr['image'] = $this->getImageData($arr['image'], $imageSize);
$arr['image'] = $this->maybeGetImageImageContract($displayAs, $arr['image']) ?? $this->getImageData($arr['image'], $imageSize);
$arr['accordion_column_values'] = $this->createAccordionTitles($arr['accordion_column_values'], $arr['title']);
$arr['view'] = $this->getInputView($arr['isHighlighted']);
$arr['columnSize'] = $this->getInputColumnSize($fields, $arr['isHighlighted']);
Expand All @@ -60,6 +64,18 @@ public function data(): array
return $data;
}

private function maybeGetImageImageContract(string $displayAs, int $imageId) {
if (in_array($displayAs, ['segment'])) {
return ImageComponentContract::factory(
$imageId,
[1920, false],
new ImageResolver()
);
}

return null;
}

/**
* @return array Array with default values
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'layout' => 'card',
'title' => $input['title'],
'context' => $context,
'image' => $input['image']['src'],
'image' => $input['image'],
'content' => $input['content'],
'buttons' => [['text' => $input['linkText'], 'href' => $input['link'], 'color' => 'primary']],
'containerAware' => true,
Expand Down
Loading