Support

Home Forums Event Espresso Premium grab event image

grab event image

Posted: June 23, 2014 at 5:05 am

Viewing 6 reply threads


blue level

June 23, 2014 at 5:05 am

hi i want to be able to dynamicly grab the event featured image so if i changed the image in event espresso it changed wherever i put the code

at the moment i have

<div id="espresso_featured_image-17" class="ee-product-image"<
a href="http://blue-carrots.com/event-registration/?ee=17" style="position: relative; overflow: hidden;">

<img src="http://somthing.com/wp-content/uploads/2014/06/documentation.png"" title="Featured Image" />

i need to to be somthing like get event 17 featured image


Dean

June 23, 2014 at 5:23 am

Hi,

Are you using EE3 or EE4?


blue level

June 23, 2014 at 7:50 am

EE3


Josh

  • Support Staff

June 23, 2014 at 9:04 pm

Hi Blue,

It depends on the context of the code you’re working with. Is this a page template, an Event Espresso event template, or something else?

It may help to take a look at the way the event-list-display.php template grabs the event image:

echo apply_filters('filter_hook_espresso_display_featured_image', $event_id, !empty($event_meta['event_thumbnail_url']) ? $event_meta['event_thumbnail_url'] : '');

Note that earlier in event_list.php that $event_id and $event_meta get set by the current event ID in the loop. You can base your code off this, or alternatively check out the espresso_get_event function that’s located in /event-espresso/includes/functions/main.php.


blue level

June 24, 2014 at 2:08 am

its part of a page template that will display when there is no events

<code>
&lt;div class=&quot;event-data-display ui-widget-content ui-corner-bottom&quot;&gt;
&lt;div id=&quot;espresso_featured_image-17&quot; class=&quot;ee-product-image&quot;&gt;
&lt;a href=&quot;http://blue-carrots.com/event-registration/?ee=17&quot; style=&quot;position: relative; overflow: hidden;&quot;&gt;
&lt;img src=&quot;http://blue-carrots.com/wp-content/uploads/2014/06/documentation.png&quot; title=&quot;Featured Image&quot;&gt;
&lt;span class=&quot;image-overlay overlay-type-extern&quot; style=&quot;display: none;&quot;&gt;
&lt;span class=&quot;image-overlay-inside&quot;&gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/a&gt;
&lt;/div&gt;	
					
&lt;div class=&quot;event-meta&quot;&gt;
&lt;p class=&quot;product_price&quot; id=&quot;p_event_price-17&quot;&gt;
&lt;span class=&quot;section-title&quot;&gt;Price: 
&lt;/span&gt; £145.00
&lt;/p&gt;
&lt;/div&gt;

&lt;p class=&quot;product-register-link-footer&quot; id=&quot;register_link-17&quot;&gt;
&lt;a direct_to_cart=&quot;0&quot; moving_to_cart=&quot;Please+wait+redirecting+to+cart+page&quot; title=&quot;Personal Licence Application&quot; href=&quot;http://blue-carrots.com/event-registration/?event_id=17&quot; id=&quot;cart_link_17&quot; class=&quot;ee_view_cart ee_add_item_to_cart&quot;&gt;Add to Basket&lt;/a&gt;				
&lt;/p&gt;

&lt;/div&gt;&lt;!-- / .event-data-display --&gt;
&lt;/div&gt;&lt;!-- / .event-display-boxes --&gt;

</code>

insted of the image code i want it to be dynamic so if event 17 is updated the image will be changed


Tony

  • Support Staff

June 24, 2014 at 4:39 am

So event 17 is the event that will always be displayed in this situation?

If so you could us the event_espresso_get_event_meta() function to pull the event meta and then echo the thumbnail using the code Josh provided.

Something like

$event_id = 17;
$event_meta = event_espresso_get_event_meta($event_id);

Will pull all the event_meta for event 17.

Then as Josh pointed out, use:

echo apply_filters('filter_hook_espresso_display_featured_image', $event_id, !empty($event_meta['event_thumbnail_url']) ? $event_meta['event_thumbnail_url'] : '');

to output the link for the thumbnail URL.


blue level

June 24, 2014 at 5:04 am

works a treat
thanks guys

Viewing 6 reply threads

The support post ‘grab event image’ 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