Forum Replies Created
-
AuthorPosts
-
January 12, 2015 at 9:46 pm in reply to: Set organizer featured image as the default event featured image #931847MarcParticipant
I found a solution, but it seems rather cumbersome. I would think a cleaner solution would be possible using WP’s native thumbnail functions, but I can’t figure it out.
When I use the “tribe_event_featured_image” function, it replaces the images well wherever that function is loaded in the templates. However, I also use for example the Genesis Framework and their Responsive Slider plugin. The solution with the tribe function didn’t populate the slider with the featured image, as that was called with the “genesis_image” function (which uses and filters WP’s thumbnail function).
That’s why I think a function that deals with the native capabilities would be better too. But here’s the code that made it possible for me to display the organizer’s featured image as the event’s featured image if no featured image was set.
/** Define a default post thumbnail Genesis */ function default_event_image_fallback($output, $args) { global $post; if( $output || $args['size'] == 'full' && get_post_type() == 'tribe-events' ) return $output; $post_id = tribe_get_organizer_id(); $image_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), $size ); $thumbnail = $image_src[0]; switch($args['format']) { case 'html' : return '<img src="'.$thumbnail.'" class="attachment-'. $args['size'] .'" alt="'. get_the_title($post_id) .'" />'; break; case 'url' : return $thumbnail; break; default : return $output; break; } } add_filter('genesis_get_image', 'default_event_image_fallback', 10, 2); /** Define a default post thumbnail Events Calendar */ function set_default_event_featured_img( $featured_image, $post_id, $size, $image_src ) { if ( ! $featured_image ) { $post_id = tribe_get_organizer_id(); $image_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), $size ); $featured_image = ''; //if link is not specifically excluded, then include <a> if ( ! empty( $image_src ) && $link ) { $featured_image .= '<div class="tribe-events-event-image"><a href="' . tribe_get_event_link() . '" title="' . get_the_title( $post_id ) . '"><img src="' . $image_src[0] . '" title="' . get_the_title( $post_id ) . '" /></a></div>'; } elseif ( ! empty( $image_src ) ) { $featured_image .= '<div class="tribe-events-event-image"><img src="' . $image_src[0] . '" title="' . get_the_title( $post_id ) . '" /></div>'; } return apply_filters( 'tribe_event_featured_image', $featured_image, $post_id, $size, $image_src ); } else { return $featured_image; } } add_filter( 'tribe_event_featured_image', 'set_default_event_featured_img', 10, 4 );
April 8, 2014 at 10:15 am in reply to: Using the Organizer's featured image as the Event's featured image #129568MarcParticipantI realize you guys can’t respond to customizations all the time, but I figured this one would be very helpful for the community as well. As you mentioned, it would be a good addition to the code snippets. Could one of your developers do a quick fix to my code?
April 8, 2014 at 10:13 am in reply to: Using the Organizer's featured image as the Event's featured image #129564MarcParticipantI’m not going to figure this one out by myself… with the filter, I don’t know what hook to tie into. There’s a lot of other questions I have… Is this better?
add_filter( ‘WHAT HOOK?’, ‘set_featured_event_image’, 1);
function set_featured_event_image ( $featured_event_image ) {
if ( get_post_type() == ‘tribe_events’) {
if ( has_post_thumbnail() ) {
$featured_event_image = $post_thumbnail_id
} else {
$featured_event_image = GRAB THE ORGANIZER THUMBNAIL?
}
}
}
return $featured_event_image;
}April 5, 2014 at 9:54 pm in reply to: Using the Organizer's featured image as the Event's featured image #128614MarcParticipantThanks! I really don’t think this code works. I’m not a developer. But I wanted to try to figure out some of the basics, hoping that you guys would take it and fix it or give some pointers. I would love someone on the Tribe team to look at it and fix it.
I agree it could be a very valuable addition to a useful snippet list. I post lots of events and use the featured image of event posts in a home page slider. It would be great not to have to upload individual images for each event, but rely on the organizer’s image.
April 4, 2014 at 3:13 pm in reply to: Using the Organizer's featured image as the Event's featured image #128342MarcParticipantHere is a very uneducated attempt. I’m sure I have some things really, really wrong. But figured I get something started.
Here are the basics I need:
* Function needs to run if post type = tribe_events
* If the post has a featured image, it should do nothing
* If the post does not have a featured image, it should look at what the event’s organizer is and take the featured image from that organizer post.
* Save or update the post and it will assign a featured image based on above criteriaHere’s my attempt for functions.php:
/** Check if an Tribe Event post has a Post Thumbnail, if not set associated Tribe Organizer as Post Thumbnail */
function organizer_featured() {
if ( ‘tribe_events’ == get_post_type() ) {
if ( has_post_thumbnail() ) {
// nothing should happen
}
else {
set_post_thumbnail($post, $thumbnail_id) {
$post = tribe_get_organizer_id ();
}
}
}
add_action(‘the_post’, ‘organizer_featured’);
add_action(‘save_post’, ‘organizer_featured’);
add_action(‘draft_to_publish’, ‘organizer_featured’);
add_action(‘new_to_publish’, ‘organizer_featured’);
add_action(‘pending_to_publish’, ‘organizer_featured’);
add_action(‘future_to_publish’, ‘organizer_featured’);July 25, 2013 at 1:37 pm in reply to: Genesis Responsive Slider doesn’t pull from ‘featured’ category #57196MarcParticipantThe tag issue got fixed with 3.0.2.
Both questions are now answered, thanks!
July 17, 2013 at 7:29 am in reply to: Genesis Responsive Slider doesn’t pull from ‘featured’ category #55686MarcParticipantHi Jonah,
Here’s a sample: http://atxclassical.org/event/ballet-austin-a-midsummer-nights-dream-friday/
In the event details, under ‘Event tags:’ when I click Ballet Austin, the URL is http://atxclassical.org/events/tag/BalletAustin/ where the URL should be http://atxclassical.org/events/tag/ballet-austin/
Is it maybe something in the tribe_meta_event_tags function?
MarcParticipantCool. Thank you both. Looks like I have a little brushing up/learning to do, but it looks manageable to do. Thanks for the pointers.
July 16, 2013 at 1:11 pm in reply to: Genesis Responsive Slider doesn’t pull from ‘featured’ category #55517MarcParticipantThanks, Jonah! I really appreciate the help there. It works slightly different from the 2.x versions (it pulls all events in the featured category, including expired events), but I actually like this better. Thanks again for the help.
Secondly, I cleared the permalinks, but that didn’t seem to correct the tag issue. Interestingly, I don’t have this issue with regular post types. Is there anything specifically you need to know to further investigate this issue?
MarcParticipantThanks for getting back to me. I have looked at the themer’s guide, and I have gone through the single-event.php template. But that’s not where this stuff is housed.
In 2.x each individual meta field was in the template file and I could edit there. In 3.x, it seems the meta fields get pulled from meta.php, which seems to be part of the core plugin?
Do I edit the meta.php file? I assume not? But it looks like, if I want to edit the “Events tags:” output, I can find it here:
http://docs.tri.be/Events-Calendar/source-class-Tribe_Register_Meta.html#289-300
I don’t want to be editing the core plugin though… this should all be done through custom template files in /your-theme/tribe-events
MarcParticipantAny news? Here’s a related post too: https://theeventscalendar.com/support/forums/topic/where-to-edit-meta-output-and-labels/
July 15, 2013 at 2:56 pm in reply to: Genesis Responsive Slider doesn’t pull from ‘featured’ category #55280MarcParticipantOn the tags… I’m not asking for any kind of customization. You enabled tags for events, so I assume you want it to work…
I have limited knowledge, but from what I understand, is that the output of the tag slug in the meta boxes of the single-event view is incorrect. Perhaps you’re calling the tag name for the link instead of the tag slug?
Maybe found something in here? http://docs.tri.be/Events-Calendar/source-function-tribe_meta_event_tags.html#293-315
Look at this page: http://atxclassical.org/event/ballet-austin-a-midsummer-nights-dream-friday/
Ballet Austin should have an output as ballet-austin for the slug, not BalletAustin, and Stephen Mills should have an output as stephen-mills for the slug, not StephenMills.
Again, this is not a customization, but it is now part of the core plugin, since you enabled tags. I’m not asking about the tag archive pages here, I’m asking about a bug in the output of the tag slug on the single event pages’ meta boxes.
July 15, 2013 at 2:32 pm in reply to: Genesis Responsive Slider doesn’t pull from ‘featured’ category #55271MarcParticipantThanks, Jonah. I did no customizations in order to set up the slider properly. The slider has a settings page where you can select the post type to pull from and the category or tag to pull from for each post type. Here is the slider plugin I used: http://wordpress.org/plugins/genesis-responsive-slider/
The difference between 2.x and 3.x:
* In 2.x when an event expired, it would not display it in the slider. In 3.x expired events display in the slider if they are in the current month.
* In 2.x upcoming events from upcoming months would display as long as they were in the selected category. In 3.x events from the selected category only display from the current month.July 15, 2013 at 9:22 am in reply to: Genesis Responsive Slider doesn’t pull from ‘featured’ category #55217MarcParticipantI see the issue now with the tag archive page. It’s not based on current month. On the event page (single-event), a tag with a space (e.g. ‘Stephen Mills’) gets translated into a URL with the space removed (e.g. http://atxclassical.org/events/tag/StephenMills/), where it should get translated into a URL with a dash (e.g. http://atxclassical.org/events/tag/Stephen-Mills/).
This is a bug that needs a fix.
But I still would also like insights into what changed with the slider. Only current month events get pulled into the slider, whereas before any event in the category ‘featured’ would get pulled, as long as the event hadn’t passed. If this is a custom fix I need to do, that’s fine, but I’d love some direction.
MarcParticipantI have, what I believe, is a similar problem. In 2.x I had added category buttons above the gridview. This worked fine in 2.x. Now in 3.x I can only see the current month by category. If I move to the next month or previous month, it shows all categories again.
Here’s the grid: http://atxclassical.org/events/
Here’s the category view: http://atxclassical.org/events/category/ballet/month/
Here’s the category view that doesn’t work: http://atxclassical.org/events/category/ballet/2013-04/ -
AuthorPosts