fbpx

How can we help?

Limit the banner Size

An event banner in WP Event Manager plays a pivotal role in attracting your target audience toward your event. It displays your event details and catches the attention of your audience with its exclusive designs and images.

However, to ensure that your website runs smoothly, you need to instruct the event organizers about the banner size as well. This is because too big banner images can affect your website speed. A maximum of 2MB image file can be accepted from everyone.

So how to limit the banner image size? You will learn about the steps in this guide.

Here are the steps that you need to take to limit the event banner size:

  1. Open your child theme function.php.
  2. Add the following code:
    add_filter('event_manager_upload_file_pre_upload', 'wpem_event_manager_upload_file_pre_upload', 10, 3);
       function wpem_event_manager_upload_file_pre_upload($file, $args, $allowed_mime_types)
        {
            if(!empty($file))
            {
                if(isset($file['size']) && $file['size'] > 400000 )
                {
                    return new WP_Error( 'validation-error', __( 'Event banner size no more than 400kb.', 'wp-event-manager' ) );
                }
            }
    
            return $file;
        }
    
Was this article helpful?
How can we improve this article?
How Can We Improve This Article?
Quick Links
Close