feature request: support self registered images sizes for #_EVENTIMAGE
-
I wanted an #_EVENTIMAGE{100,100} placeholder to crop the image accordingly to the dimensions. Perhaps I missed something essential but that doesn’t seem to be possible, the images where always distorted.
To solve this, I modified the code in classes/em-event.php like that:
case '#_EVENTIMAGE': if($this->get_image_url() != ''){ if($result == '#_EVENTIMAGEURL'){ $replace = esc_url($this->image_url); }else{ if( empty($placeholders[3][$key]) ){ $replace = "<img src='".esc_url($this->image_url)."' alt='".esc_attr($this->event_name)."'/>"; }else{ $image_size = explode(',', $placeholders[3][$key]); $image_url = $this->image_url; if( self::array_is_numeric($image_size) && count($image_size) > 1 ){ //get a thumbnail if( get_option('dbem_disable_thumbnails') ){ $image_attr = ''; $image_args = array(); if( empty($image_size[1]) && !empty($image_size[0]) ){ $image_attr = 'width="'.$image_size[0].'"'; $image_args['w'] = $image_size[0]; }elseif( empty($image_size[0]) && !empty($image_size[1]) ){ $image_attr = 'height="'.$image_size[1].'"'; $image_args['h'] = $image_size[1]; }elseif( !empty($image_size[0]) && !empty($image_size[1]) ){ $image_attr = 'width="'.$image_size[0].'" height="'.$image_size[1].'"'; $image_args = array('w'=>$image_size[0], 'h'=>$image_size[1]); } $replace = "<img src='".esc_url(em_add_get_params($image_url, $image_args))."' alt='".esc_attr($this->event_name)."' $image_attr />"; }else{ if( EM_MS_GLOBAL && get_current_blog_id() != $this->blog_id ){ switch_to_blog($this->blog_id); $switch_back = true; } $replace = get_the_post_thumbnail($this->ID, $image_size); if( !empty($switch_back) ){ restore_current_blog(); } } } elseif (count($image_size) === 1) { if( EM_MS_GLOBAL && get_current_blog_id() != $this->blog_id ){ switch_to_blog($this->blog_id); $switch_back = true; } $image_size = $image_size[0]; $replace = get_the_post_thumbnail($this->ID, $image_size); if( !empty($switch_back) ){ restore_current_blog(); } } else { $replace = "<img src='".esc_url($image_url)."' alt='".esc_attr($this->event_name)."'/>"; } } } } break;
So, now I’m able to do something like that:
add_action( 'after_setup_theme', 'my_after_setup_theme' ); function my_after_setup_theme() { add_image_size( 'custom-size', 100, 100, true ); }
and can use the placeholder in that way: #_EVENTIMAGE{custom-size}
Perhaps it would be possible to add this feature to events-manager.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘feature request: support self registered images sizes for #_EVENTIMAGE’ is closed to new replies.