Posted: 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 |
|
Hi, Are you using EE3 or EE4? |
|
EE3 |
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. |
|
|
its part of a page template that will display when there is no events <code> <div class="event-data-display ui-widget-content ui-corner-bottom"> <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://blue-carrots.com/wp-content/uploads/2014/06/documentation.png" title="Featured Image"> <span class="image-overlay overlay-type-extern" style="display: none;"> <span class="image-overlay-inside"></span> </span> </a> </div> <div class="event-meta"> <p class="product_price" id="p_event_price-17"> <span class="section-title">Price: </span> £145.00 </p> </div> <p class="product-register-link-footer" id="register_link-17"> <a direct_to_cart="0" moving_to_cart="Please+wait+redirecting+to+cart+page" title="Personal Licence Application" href="http://blue-carrots.com/event-registration/?event_id=17" id="cart_link_17" class="ee_view_cart ee_add_item_to_cart">Add to Basket</a> </p> </div><!-- / .event-data-display --> </div><!-- / .event-display-boxes --> </code> insted of the image code i want it to be dynamic so if event 17 is updated the image will be changed |
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. |
|
|
works a treat |
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.