Skip to content

Instantly share code, notes, and snippets.

@wpfangirl
Last active March 16, 2022 15:34
Show Gist options
  • Save wpfangirl/8bcdfca4b9f213291033effe870970f6 to your computer and use it in GitHub Desktop.
Save wpfangirl/8bcdfca4b9f213291033effe870970f6 to your computer and use it in GitHub Desktop.
Modify the Event Image Size with Filters (The Events Calendar)

Modify the Event Image Size with Filters (The Events Calendar)

Here are three ways to modify event image sizes for The Events Calendar and Events Calendar Pro. Add the function you want to either your functions.php file or a custom functions file. Do not use more than one of these functions on any given site.

// Change size of featured image on single events using post_thumbnail_size
add_filter( 'post_thumbnail_size', 'ebwp_single_event_post_thumbnail_size');
function ebwp_single_event_post_thumbnail_size($size) {
if( !is_singular('tribe_events') ) {
return;
}
if( ! has_post_thumbnail() ) {
return;
}
$size = 'large'; // Change to your desired image size.
return $size;
}
// Change size of ALL event images (but not featured images for other post types)
add_filter('tribe_event_featured_image_size', 'ebwp_event_featured_image_size');
function ebwp_event_featured_image_size($size) {
$size = 'large'; // Change to your desired image size
return $size;
}
// Change size of featured image on single events from 'full' to 'large'
add_filter('tribe_event_featured_image_size', 'ebwp_single_event_featured_image_size');
function ebwp_single_event_featured_image_size($size) {
if( ! is_singular('tribe_events') ) {
return;
}
if( ! has_post_thumbnail() ) {
return;
}
$size = 'large'; // Change to your desired image size.
return $size;
}
@jpetryy
Copy link

jpetryy commented Jan 19, 2022

Thank you so much for sharing! The 3rd one helped me immediately. The only thing that is now occuring is that every image is now shown in it's original aspect ratio. Is there any chance to keep the ratio 1:1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment