How to Disable Flash Uploader in WordPress

WPTurbo » Snippets » How to Disable Flash Uploader in WordPress
0

Created with:

Visibility: 

public

Creator: WPTurbo Team

Customize with WPTurbo AI
X

Add Snippet To Project

New Project
Add To Existing Project

Are you looking to disable the flash uploader on your WordPress website? Don’t worry, you’re not alone. Many website owners prefer to use the HTML5 uploader instead, as it offers better performance and compatibility. In this article, we will guide you through the process of disabling the flash uploader and enabling the HTML5 uploader in just a few simple steps. So, let’s dive in and make your WordPress website even better!

					function wpturbo_disable_flash_uploader( $mimes ) {
    unset( $mimes['swf'] );
    return $mimes;
}
add_filter( 'mime_types', 'wpturbo_disable_flash_uploader' );
				

The code snippet above shows how to disable the flash uploader in WordPress. The flash uploader is used by default to upload certain types of files, such as SWF (Flash) files. However, if you want to disable this functionality and prevent users from uploading SWF files, you can use the provided code.

The snippet defines a function called wpturbo_disable_flash_uploader that takes the $mimes parameter. This parameter holds an associative array of allowed file types and their corresponding MIME types in WordPress. By modifying this array, we can disable specific file types.

Inside the function, we use the unset() function to remove the ‘swf’ key from the $mimes array. This key represents the MIME type for SWF files. By removing this key, we effectively disable the flash uploader for SWF files.

Finally, we return the modified $mimes array. This is done to ensure that other MIME types and their corresponding file extensions remain unaffected by our changes.

To integrate this code into WordPress, we use the add_filter() function. We hook our wpturbo_disable_flash_uploader function into the mime_types filter. This filter allows us to modify the list of allowed MIME types before it is used by the WordPress media uploader.

By adding the filter, our custom function is called whenever WordPress needs to determine the allowed MIME types. Our function will then remove the SWF MIME type, effectively disabling the flash uploader for SWF files.

It’s important to note that this code snippet can be used in your theme’s functions.php file or within a custom plugin. Additionally, you can modify the code to disable other file types by removing their respective MIME types from the $mimes array.

Register an account to save your snippets or go Pro to get more features.