kunalb / EventPress

Events Plugin for WordPress and BuddyPress
http://wordpress.org/extend/plugins/eventpress
24 stars 7 forks source link

Added new feature to set a default image for new Events #15

Open jshoor opened 13 years ago

jshoor commented 13 years ago

I hated the fact that all my events were defaulting to having gravatars as their image. Even more so because I had selected mysteryman as my default avatar type. Anyway, I from my perspective most users are not creating Featured Images for their events, so I wanted to be able to create a custom Default Event Image. Here is the code to do so:

For this to work, an administrator first needs to create a dummy page with a featured image attachment. The name of that featured image must be "Default Event Image". You can call the page whatever you want, but I also called it "Default Event Image."

If you make the following code change, all new events without an image will now pick up your default image.

In controllers/wp.php:227 add the following:

                if (!get_post_thumbnail_id($eventid)){
                    $page = get_page_by_title( 'Default Event Image','','attachment' );
                    set_post_thumbnail($eventid, $page->ID);
                }