diff --git a/source/php/Api/Events.php b/source/php/Api/Events.php index 40d0e6e4..fd91d754 100644 --- a/source/php/Api/Events.php +++ b/source/php/Api/Events.php @@ -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; diff --git a/source/php/PostTypes/Events.php b/source/php/PostTypes/Events.php index 1c2106c0..3b027133 100755 --- a/source/php/PostTypes/Events.php +++ b/source/php/PostTypes/Events.php @@ -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);