跳到内容

Clear Media Title On Upload

v2.0.2

runthings.dev · 2026年1月27日 上架

Clears the media title field on upload, instead of setting it to the slugified filename.

正在使用
10 以下
评分
暂无
累计下载
515
最近更新
2026年11月16日
需要 WordPress 6.0+已测试到 7.1.5PHP 7.4+

贡献者

截图

Before: Image uploaded with auto-generated slugified title. After: Image uploaded with empty title field.
Before: Image uploaded with auto-generated slugified title. After: Image uploaded with empty title field.

When you upload media to WordPress, the title field is automatically set to a slugified version of the filename. This often results in messy, unoptimized titles like “IMG-20240115-photo-final-v2” appearing in gallery captions, alt tags, or title attributes.

This plugin clears the title field for newly uploaded media, ensuring that if a title is displayed anywhere, it’s one you’ve intentionally set yourself.

Features

  • Automatically clears the title field for new media uploads
  • Bulk action to clear titles on existing media library items
  • Lightweight with no settings page required
  • Developer-friendly with filters

How It Works

The plugin hooks into WordPress’s wp_insert_attachment_data filter and clears the post_title field for new uploads before they are saved to the database.

Filters

runthings_emt_skip

Skip clearing the title for specific attachments.

Parameters:

  • $skip (bool) – Whether to skip clearing the title. Default false.
  • $data (array) – Attachment post data (slashed, sanitized, processed).
  • $postarr (array) – Sanitized post data (not processed).
  • $unsanitized_postarr (array) – Unsanitized post data.
  • $update (bool) – Whether this is an update (always false for new uploads).

Example:

// Skip clearing title for uploads by specific user
add_filter('runthings_emt_skip', function($skip, $data, $postarr) {
    if (get_current_user_id() === 1) {
        return true; // Admin keeps auto-generated titles
    }
    return $skip;
}, 10, 3);



// Skip clearing title if filename contains "keep-title"
add_filter('runthings_emt_skip', function($skip, $data, $postarr) {
    $filename = $postarr['post_title'] ?? '';
    if (strpos($filename, 'keep-title') !== false) {
        return true;
    }
    return $skip;
}, 10, 3);

runthings_emt_mime_types

Filter which MIME types should have their title cleared. By default, all media types are affected.

Parameters:

  • $allowed_mime_types (array) – Array of MIME type patterns. Default [] (all types).
  • $attachment_mime_type (string) – The attachment’s MIME type.
  • $postarr (array) – Sanitized post data.

Example:

// Restrict to images only
add_filter('runthings_emt_mime_types', function($allowed_mime_types) {
    return ['image'];
});



// Restrict to images and PDFs only
add_filter('runthings_emt_mime_types', function($allowed_mime_types) {
    return ['image', 'application/pdf'];
});

Additional Notes

Built by Matthew Harris of runthings.dev, copyright 2022-2026.

Visit runthings.dev for more WordPress plugins and resources.

Contribute or report issues at the GitHub repository.

Insert space by Xinh Studio from Noun Project, https://thenounproject.com/browse/icons/term/insert-space/ (CC BY 3.0) – https://thenounproject.com/icon/insert-space-239543/

Image by David Khai from Noun Project, https://thenounproject.com/browse/icons/term/image/ (CC BY 3.0) – https://thenounproject.com/icon/image-661355/

Plums

按场景查找 WordPress 插件。安装量、评分和兼容版本来自官方目录。

导航

说明

WordPress 是 WordPress Foundation 的商标。本站与 WordPress Foundation、Automattic 没有隶属关系。这里不托管插件文件,下载和安装以 WordPress.org 上的页面为准。

© 2026 Plums