fbpx

How can we help?

Limit the banner Size

Your WP Event Manager’s event banner reflects your event and will capture the attention of your guests. One should make sure your event image looks fantastic is exclusive, inspiring, and holds the curiosity of your attendees.

However, in order to have a better functioning of the website, you cannot allow all the event organizers to publish an event banner of any size they like. A maximum of 2MB image files must be acceptable from everyone so as to reduce the loading speed of the webpage.

Hence in order to set this limitation in uploading the event banner, the following code needs to be applied.

Limit the banner Size

  1. Open your child theme function.php
  2. Add code:
    <?php
    
    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?