3

我想知道如何从 wordpress 媒体库中删除重复的图像,我还想问媒体上传器如何检查文件的重复。

4

2 回答 2

1
Get all posts. See get_posts( array ( 'numberposts' => -1 ) )
For each post get all attachments. See get_children( array ( 'post_type' => 'attachment', 'numberposts' => -1 ) )
For each attachment get the attachment URL. See wp_get_attachment_url()
If you find the attachment URL in the parent post's content ($post->post_content):
    If there is another attachment URL with the same file name plus the 1 and
    both are part of the post content then
    remove the second image first then
    use wp_delete_attachment() to delete the physical file. This will remove all meta data and all associations in other posts too. It is the best way to remove attached files (imho).
于 2013-07-01T06:36:58.150 回答
0

清理上传文件夹中未使用的图像和其他文件。

http://wordpress.org/plugins/upload-janitor/

删除未使用的图像

http://wordpress.org/plugins/dnui-delete-not-used-image-wordpress/screenshots/

不使用插件时:

go media:   Sort files by Unattached.

delete which is not used.
于 2013-07-01T07:04:36.903 回答