Skip to content

Commit

Permalink
Merge pull request #237 from helsingborg-stad/fix/deprecated-municipi…
Browse files Browse the repository at this point in the history
…o-function

fix: deprecated municipio function
  • Loading branch information
sebastianthulin authored Apr 5, 2024
2 parents c03c7f1 + 907accc commit 934e31f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 50 deletions.
44 changes: 4 additions & 40 deletions source/php/Api/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,46 +269,10 @@ public function mapEventModuleData($moduleId, $settings, $events)
$location = get_post_meta($event->ID, 'location', true);
$event->location = !empty($location['title']) ? $location['title'] : null;

// Get image url
switch ($template) {
case 'index':
if (
function_exists('municipio_get_thumbnail_source') && municipio_get_thumbnail_source(
$event->ID,
array($data['imageDimensions']['width'], $data['imageDimensions']['height']),
$data['imageRatio']
)
) {
$event->image_url = municipio_get_thumbnail_source(
$event->ID,
array($data['imageDimensions']['width'], $data['imageDimensions']['height']),
$data['imageRatio']
);
} elseif (!empty($defaultImage)) {
$src = wp_get_attachment_image_src(
$defaultImage['ID'],
municipio_to_aspect_ratio(
$data['imageRatio'],
array($data['imageDimensions']['width'], $data['imageDimensions']['height'])
)
);
$event->image_url = $src[0] ?? null;
}
break;
default:
if (
function_exists('municipio_get_thumbnail_source') && municipio_get_thumbnail_source(
$event->ID
)
) {
$event->image_url = municipio_get_thumbnail_source($event->ID);
} elseif (!empty($defaultImage)) {
$src = wp_get_attachment_image_src(
$defaultImage['ID']
);
$event->image_url = $src[0] ?? null;
}
}
if (class_exists('Municipio\Helper\Image') && $template == 'index') {
$image = \Municipio\Helper\Image::getImageAttachmentData(get_post_thumbnail_id($event->ID), [1280, 720]);
$event->image_url = !empty($image['src']) ? $image['src'] : null;
}
}

return $events;
Expand Down
13 changes: 3 additions & 10 deletions source/php/PostTypes/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,9 @@ public function singleViewData($data)
}
$eventData['content'] = apply_filters('the_content', $eventData['content']);

if (function_exists('municipio_get_thumbnail_source')) {
$eventData['image_src'] = municipio_get_thumbnail_source(
null,
array(750, 750),
'16:9'
);
} else {
$thumbnailId = get_post_thumbnail_id($post->ID);
$image = wp_get_attachment_image_src($thumbnailId, 'medium');
$eventData['image_src'] = $image[0] ?? null;
if (class_exists('Municipio\Helper\Image')) {
$image = \Municipio\Helper\Image::getImageAttachmentData(get_post_thumbnail_id($post->ID), [1280, 720]);
$eventData['image_src'] = !empty($image['src']) ? $image['src'] : null;
}

$eventData['location'] = \EventManagerIntegration\Helper\SingleEventData::getEventLocation($post->ID);
Expand Down

0 comments on commit 934e31f

Please sign in to comment.