You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何禁用WordPress Flash上传器并强制使用浏览器上传器?求方案及代码

Disable WordPress Flash Uploader & Force Browser Uploader Solutions

Hey there! Great questions—both are straightforward to solve with a bit of custom code. I’ll break down the solutions clearly, and you can drop these snippets into a custom plugin (highly recommended over editing your theme’s functions.php to avoid losing changes when your theme updates) or your child theme’s functions.php file.

1. Disable the WordPress Flash Uploader

WordPress used to rely on Flash-based uploaders (like SWFUpload) in older versions, and some legacy plugins/themes might still load them. To fully disable the Flash uploader, we’ll deregister the related scripts so WordPress can’t load them:

// Deregister all Flash uploader-related scripts
function disable_flash_uploader() {
    wp_deregister_script('swfupload');
    wp_deregister_script('swfupload-all');
    wp_deregister_script('swfupload-handlers');
}
add_action('admin_enqueue_scripts', 'disable_flash_uploader');

This code hooks into the admin_enqueue_scripts action to unregister the core Flash uploader scripts. Once added, WordPress won’t load any Flash-based uploader components.

2. Disable Flash Uploader & Force Browser-Native Uploader

If you want to go a step further and explicitly force WordPress to use the browser’s native uploader (instead of falling back to any alternative), add this filter alongside the previous function:

// Force WordPress to use the browser-native uploader
function force_browser_uploader($use_flash) {
    return false;
}
add_filter('flash_uploader', 'force_browser_uploader');

The flash_uploader filter controls whether WordPress attempts to use Flash for uploads. Returning false tells WordPress to skip Flash entirely and default to the browser’s built-in uploader.

Combined Code Snippet

Here’s both functions together for convenience:

// Disable Flash Uploader and Force Browser Uploader
function disable_flash_uploader() {
    wp_deregister_script('swfupload');
    wp_deregister_script('swfupload-all');
    wp_deregister_script('swfupload-handlers');
}
add_action('admin_enqueue_scripts', 'disable_flash_uploader');

function force_browser_uploader($use_flash) {
    return false;
}
add_filter('flash_uploader', 'force_browser_uploader');

Important Notes

  • Use a Custom Plugin: Creating a simple custom plugin to hold this code is better than editing your theme’s files—theme updates will overwrite any changes in functions.php.
  • Compatibility: This works for most WordPress versions (especially 3.5+, where native uploaders became default). If you’re on an extremely old version, you might need to adjust, but modern installs will handle this perfectly.
  • Plugin Conflicts: If you still see the Flash uploader after adding this code, check if a third-party plugin is re-registering the Flash scripts. You can adjust the action priority (add a third parameter like 100 to add_action) to ensure your code runs last.

内容的提问来源于stack exchange,提问作者Amr Elkady

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 07:42:49