Support

Home Forums Event Espresso Premium Display event photo

Display event photo

Posted: October 15, 2012 at 4:25 pm

Viewing 6 reply threads


Stuart Buchanan

October 15, 2012 at 4:25 pm

Thought I’d share how to display an event photo within a post page since I didn’t find clear instructions on how to do it. I created a content-single-espresso_event.php and single-espresso_event.php pointing to it. this is the code:

ID); 
    global $event_meta;
    $event_meta = unserialize($meta_values["event_meta"][0]);
    $event_meta = unserialize($event_meta);

if (isset($event_meta["event_thumbnail_url"])){
    $img1[0] = $event_meta["event_thumbnail_url"];
    $size = getimagesize($event_meta["event_thumbnail_url"],$info);
    $img1[1] = $size[0];
    $img1[2] = $size[1];
}
?>

<img src="" width="" height="" alt="" />


Chris Reynolds

  • Support Staff

October 15, 2012 at 4:57 pm

You don’t even need to do all that if you don’t want to. You can use the EE_META shortcode to pull the event_thumbnail_url, e.g.:

<img src="<?php echo do_shortcode('[EE_META type="event_meta" event_id="' . $event_id . '"name="event_thumbnail_url"]'); ?>" alt="<?php echo $event_name; ?>" />

Alternately, in your event_list.php (or registration_page.php), you could just add $event_thumb as a variable. So if I wanted to do that in the event list, I could go to lines 232 – 241 which is this:

        global $event_meta;
        $event_meta = unserialize($event->event_meta);
        $event_meta['is_active'] = $event->is_active;
        $event_meta['event_status'] = $event->event_status;
        $event_meta['start_time'] = empty($event->start_time) ? '' : $event->start_time;
        $event_meta['start_date'] = $event->start_date;
        $event_meta['registration_start'] = $event->registration_start;
        $event_meta['registration_startT'] = $event->registration_startT;
        $event_meta['registration_end'] = $event->registration_end;
        $event_meta['registration_endT'] = $event->registration_endT;

…and add one more line at the bottom, like this:

        global $event_meta;
        $event_meta = unserialize($event->event_meta);
        $event_meta['is_active'] = $event->is_active;
        $event_meta['event_status'] = $event->event_status;
        $event_meta['start_time'] = empty($event->start_time) ? '' : $event->start_time;
        $event_meta['start_date'] = $event->start_date;
        $event_meta['registration_start'] = $event->registration_start;
        $event_meta['registration_startT'] = $event->registration_startT;
        $event_meta['registration_end'] = $event->registration_end;
        $event_meta['registration_endT'] = $event->registration_endT;
        $event_meta['event_thumbnail_url'] = $event->event_thumbnail_url;
        $event_thumb = $event_meta['event_thumbnail_url'];

Then do your if ( isset($event_thumb) ) { /* display thumb */ business in the `event_list_display.php. But the easier solution would be the EE_META shortcode.

https://eventespresso.com/wiki/shortcodes-template-variables/#ee-meta

  • This reply was modified 12 years, 2 months ago by Chris Reynolds. Reason: added link to shortcodes doc


Stuart Buchanan

October 16, 2012 at 12:03 am

how do you do it outside of the event list?
within a single post page i get my event id with:

$event_id = get_post_meta($post-&gt;ID, 'event_id', true);

then i put in the following and get nothing:

&lt;img src=&quot;" alt="" /&gt;

how do i fetch my event data into an object?


Stuart Buchanan

October 16, 2012 at 12:04 am

didn’t seem to put in the code correctly. here it is again:

ID, 'event_id', true); ?&gt;
&lt;img src=&quot;" alt="" /&gt;


Stuart Buchanan

October 16, 2012 at 12:10 am

it keeps breaking the code when putting it in.
my code was just missing a space. figured it out. the solution from the list of shortcodes worked.
https://eventespresso.com/wiki/shortcodes-template-variables/#ee-meta

[EE_META type="event_meta" event_id="' . $event_id . '" name="event_thumbnail_url"];


Stuart Buchanan

October 16, 2012 at 12:13 am

is it possible to resize the image being fetched similar to what is being inserted into the functions thumbnail sizes?
add_image_size( ‘small-feature’, 500, 300 );


Chris Reynolds

  • Support Staff

November 4, 2012 at 9:15 am

Hi Stuart —

Sorry about the delay in responding. It’s not possible to use add_image_size() because the featured images in Event Espresso are not using the post thumbnail API (because events are not posts, so we can’t use it). There are a couple ways to limit the size that gets displayed:

  1. Use CSS to set the image size. This doesn’t change the actual size of the file (so if it’s a 2000K file, it will still be loading the full image, just shrunk to fit your CSS rule), but it’s a quick and dirty solution.
  2. Use the media uploader’s image sizes (thumbnail/small/medium/etc) when you are selecting your image and hitting Insert Into Post — that will use the cropped/thumbnail version instead of the full size version.
Viewing 6 reply threads

The support post ‘Display event photo’ 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