Support

Home Forums Event Espresso Premium Featured image in calendar tool tip

Featured image in calendar tool tip

Posted: December 20, 2017 at 7:54 am

Viewing 3 reply threads


gharris@ibiweb.org

December 20, 2017 at 7:54 am

I would like the featured image of the event to appear in the tool tip along with the excerpt, (rather than in the calendar itself). This seems intuitive but cannot find any documentation. thank you.


gharris@ibiweb.org

December 20, 2017 at 11:07 am

Would something like this work in my child theme functions.php?

add_filter( 'FHEE__EE_Datetime_In_Calendar__to_array_for_json__description', 'custom_cal_desc' );
function custom_cal_desc( $mydesc ){
   $featuredimg = get_the_post_thumbnail();
   $mydesc = $mydesc . $featuredimg;
   return $mydesc;
}


gharris@ibiweb.org

December 20, 2017 at 11:23 am

Got it to work with the following:

function custom_cal_desc( $description, $datetime_in_calendar ){
	$event = $datetime_in_calendar->event();
	if( $event instanceof EE_Event ){
		$description = $event->short_description( 55, NULL, TRUE );
		if ( empty( $description )) {
			$description = $event->description_filtered();
			// better more tag detection (stolen from WP core)
			if ( preg_match( '/<!--more(.*?)?-->/', $description, $matches ) ) {
				$description = explode( $matches[0], $description, 2 );
				$description = array_shift( $description );
       				$description = strip_tags( $description,'<em><p><br><strong>' );
			}
		}
		$description = do_shortcode( $description );
	}
   
   $image = $event->feature_image( 'full' );

   $description = $image . $description;
	return $description;
}
add_filter('FHEE__EE_Datetime_In_Calendar__to_array_for_json__description', 'custom_cal_desc', 10, 2 );


Tony

  • Support Staff

December 21, 2017 at 3:47 am

Hi there,

That looks like my function here:

https://gist.github.com/Pebblo/d80ea24588fdc02ea21692aef89704d9

and whilst that’s fine to use as is, it also adds support for HTML tags in the calendar description which you may not want/need?

You could do something like:

$event = $datetime_in_calendar->event();
if( $event instanceof EE_Event ){
    $image = $event->feature_image( 'full' );
    if( !empty( $image ) ) {
        $description = $image . $description;
    }
} 
return $description;

To add the image to the ‘original’ description to save on the additional processing (although its not a lot).

Either way, I’m glad you found a solution 🙂

Viewing 3 reply threads

The support post ‘Featured image in calendar tool tip’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso