Skip to content

Commit e56d37c

Browse files
committed
Legacy templates passed wrong data in mc_get_event_image.
1 parent 564bb4e commit e56d37c

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/my-calendar-output.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -719,15 +719,21 @@ function mc_get_details( $data, $template, $type ) {
719719
* Get image for an event
720720
*
721721
* @param object $event Event object.
722-
* @param array $data event tags.
722+
* @param array $data Event tags array.
723723
* @param string|array $size Image size as expected by `get_the_post_thumbnail`.
724724
*
725725
* @return string HTML output
726726
*/
727727
function mc_get_event_image( $event, $data, $size = '' ) {
728728
$image = '';
729+
$sizes = get_intermediate_image_sizes();
730+
if ( $size && ! in_array( $size, $sizes, true ) ) {
731+
// I don't want thumbnail, which is first, but the end is likely to be custom sizes.
732+
// Shift twice, so you'll probably end up with medium or medium_large.
733+
$size = array_shift( $sizes );
734+
$size = array_shift( $sizes );
735+
}
729736
if ( ! $size ) {
730-
$sizes = get_intermediate_image_sizes();
731737
if ( in_array( 'large', $sizes, true ) ) {
732738
$default_size = 'large';
733739
} else {
@@ -801,7 +807,6 @@ function mc_get_event_image( $event, $data, $size = '' ) {
801807
if ( $override && is_singular( 'mc-events' ) && has_post_thumbnail( $event->event_post ) && current_theme_supports( 'post-thumbnails' ) && ( 'single-mc-events.php' !== $template_file_name ) ) {
802808
return '';
803809
}
804-
805810
return $image;
806811
}
807812

src/templates/legacy-functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ function mc_legacy_template_draw_event( $event, $type, $process_date, $time, $te
203203
}
204204

205205
if ( 'true' === $display_image || mc_output_is_visible( 'image', $type, $event ) ) {
206-
$img = mc_get_event_image( $event, $data );
206+
$img = mc_get_event_image( $event, $data['tags'] );
207207
}
208208

209209
if ( 'calendar' === $type ) {

0 commit comments

Comments
 (0)