Home › Forums › Calendar Products › Events Calendar PRO › Default Photo
- This topic has 2 replies, 3 voices, and was last updated 10 years, 9 months ago by
Support Droid.
-
AuthorPosts
-
June 23, 2015 at 4:25 pm #972405
Jen Russo
ParticipantHad this solution solved in another thread, here. This was with the previous TEC plugin 3.9 versions and now some images are being duplicated or some images have two images being displayed. The idea is to have an image be displayed as the feature image if the event does not have a feature image which will be taken from the venues image. If the venue or featured image does not have an image then a default logo image will displayed.
Here is the code that was working with the TEC 3.9 version:
<?php /* * If you already have something in your functions.php, please remove these first few lines */ add_filter( 'tribe_event_featured_image', 'tec_forum_938271', 11, 4 ); function tec_forum_938271( $featured_image, $post_id, $size, $image_src ){ if ( ! empty( $image_src ) ){ return $featured_image; } if ( ! tribe_is_event( $post_id ) ){ return $featured_image; } $event = get_post( $post_id ); $venue = get_post( tribe_get_venue_id( $event->ID ) ); $venue_featured = wp_get_attachment_image_src( get_post_thumbnail_id( $venue->ID ), $size ); if ( ! empty( $venue_featured ) ){ $image_url = $venue_featured[0]; } else { // Default URL $image_url = 'http://placehold.it/300x300'; } $featured_image .= '<div class="tribe-events-event-image"><img src="' . $image_url . '" title="' . get_the_title( $event->ID ) . '" alt="' . get_the_title( $event->ID ) . '" /></div>'; return $featured_image; }June 24, 2015 at 6:42 am #972540Barry
MemberHi @mauitime,
Try changing the line reading:
if ( ! empty( $image_src ) ){To:
if ( ! empty( $featured_image ) ){This is needed because a change in the actual filter hook means the
$image_srcvariable is no longer available. Does that work for you?(Though you don’t have to, you could further tidy things up by removing
$image_srcfrom the list of arguments accepted by the function. I’ve asked Gustavo to update the snippet in question.)July 9, 2015 at 7:30 am #985028Support Droid
KeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘Default Photo’ is closed to new replies.
