Skip to content

Commit

Permalink
feat: use image contract
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Thulin committed Oct 3, 2024
1 parent dd7046d commit 4bb04c6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions source/php/Module/Timeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace ModularityTimeline;

use ModularityTimeline\Helper\CacheBust;

use Modularity\Integrations\Component\ImageResolver;
use Modularity\Integrations\Component\ImageFocusResolver;
use ComponentLibrary\Integrations\Image\Image as ImageComponentContract;
class Timeline extends \Modularity\Module
{
public $slug = 'timeline';
Expand Down Expand Up @@ -31,8 +33,12 @@ public function data(): array
$event['format'] = get_field('timeline_format', $this->ID);
$eventTimeDate = $event['format'] ? substr($event['timestamp'], 0, -3) : $event['date'];
$event['timelineDate'] = $this->timelineDate($this->ID, $eventTimeDate);
if (!empty($event['image'])) {
$event['imageSrc'] = wp_get_attachment_image_src($event['image']['ID'], array('700', '400'));
if (!empty($event['image']) && isset($event['image']['ID'])) {
$event['imageSrc'] = ImageComponentContract::factory(
$event['image']['ID'],
[1024, false],
new ImageResolver()
);
}
}

Expand Down

0 comments on commit 4bb04c6

Please sign in to comment.