Delete not used image wordpress DNUI

25 febrero, 2012

This Page is for DNUI version 2.4 working in WordPress 4.4

DNUI PRO

DNUI PRO is a extends version of the open source version, this contains

Buy the DNUI PRO version

What is DNUI

Delete Not Used Image is one wordpress plugin that will help you to find all image that they aren’t in use in any wordpress post or page, this will explain better after.

Why you want to delete unused image? Well when you upload one image to wordpress, this one will make 4 sizes of the original one (maybe more or less than 4), so you will have 5 image for one upload, you probably will use one or two size for show the image, so the others 3 sizes will stay in your server doing nothing, well not nothing, they will be occupy  space in your server and database, so if you don’t have a lots of space in your server and database, you will arrive to have one big problem with  the server and database space.

WordPress doesn’t have the option to delete this sizes, the only native options is delete the original image with all sizes, if and only if you don’t use any of the original and sizes of one image. So this plugin will find all the image that aren’t use in your WordPress site.

How work

When you upload one image to your WordPress site, this one will be attached to post/page that you make the upload or if you use the uploader without any post/page, this will be attached to the last post made. When you put this image in the post/page, you will have some img url in the text, something like this

<a href=”https://www.nicearma.com/wp-content/uploads/2014/07/facebook-conexiones-21.png”><img class=”aligncenter size-medium wp-image-2968″ src=”https://www.nicearma.com/wp-content/uploads/2014/07/facebook-conexiones-21-600×554.png” alt=”facebook conexiones 2″ width=”600″ height=”554″ /></a>

If you see i have the original image facebook-conexiones-21.png and facebook-conexiones-21-600×554.png the medium size 600×554

So the plugin DNUI will get all the images from the database and try to find the match between then and all post/page made, if any match is found the plugin will think that the image or sizes are not used, so you can have the option to delete it.

And what happen if you use WordPress for another think that make post or page, well this plugin can fail, because you install some plugins that change how WordPress work, but don’t worry, you have one option that will help you to make the plugin work anyway.

Understand the plugin

You have 4 menu parts

dnui_tabsWarning:

I put important information, you have to read this!!!

IMAGES

dnui_image_tab

This will show you all the images of your WordPress Site, with labels USED or NOT- USED

You will have the rights to delete:

BACKUP:

You can configure the plugin to make backups of all image deleted by this plugin, but is a very simple logic and is not for extend use, if you want a very powerfull backup logic, you can use another plugin before of use this plugin.

OPTION:

One of the more important part of this plugin, all configuration will made here (all change will be save automatically).

Recommendations

Installation

The easy way:

The hard way:

Why the name

Well the last explication will be the name Delete Not Used image, you maybe you will ask why not Delete Unused Image, well the problem was, that the first version of this one was a remake of one plugin took of the web DUI, so make a remake and put the same name was not a very good idea. And i pick this name because i’m from some Spanish country, i live in France so i speak all the time french and if i use the same logic of this last 2 language the name will be similar. But at this moment i see a lots of plugin like this one but with somes better names like cleanup image wordpress, clean image, clean image upload, but are the same that mine.

33 Comments
lisa
10 marzo, 2012 @ 7:52 PM

where can i download this plugin

Responder
lisa
10 marzo, 2012 @ 7:53 PM
29 marzo, 2012 @ 1:24 AM

any chance of getting this working on WP3 multi site installs? It only seems to work on the main site in a multisite network install. i.e it works on mydomain.com but not subdomain.mydomain.com

cheers,

Responder
    nicearma
    29 marzo, 2012 @ 4:45 AM

    Yes, this weekend i going to try to adapt the code for multi site

Dmitry
5 abril, 2012 @ 8:40 AM

Can you add an option to select all files instead of selecting them one by one?
Thank you,
Dmitry

Responder
nicearma
7 abril, 2012 @ 6:47 AM

sorry i going to work in this plugin, but i was very sick, i will make change for put a button for select all and code for work with multisite, but first i have to feel better

Responder
Dmitry
7 abril, 2012 @ 8:13 AM

Sure no problem, I hope you get better soon 🙂

Responder
Darkness
9 abril, 2012 @ 4:14 AM

I tested the plugin on my site as I have literally thousands of unused images. Doesn’t seem to be working properly as it’s deleted images that clearly were in use on pages.

Responder
    nicearma
    9 abril, 2012 @ 9:14 AM

    Do you have or use other plugin for images? Like i explain, this plugin search if the image is used in any post and page, is easy see if the plugin going to work because only you have to go to any post or page and see en the part html if the image is referred like the name
    For example the image

    example.jpg

    have to be referred like
    example15x15.jpg‘ >
    if you dont find this type of code html in your post or page, this plugin is going to fail, thar is why i’m asking if you use plugin, because i see plugin who use another type of logic

  • Pingback: DNUI Delete not used image | Best Plugins - wordpress – widgets – plugin 2012

  • nicearma
    17 abril, 2012 @ 2:10 PM

    @Dmitry Add button for select all, @sean i promest to work this week in the multisite option, i was seek two time

    Responder
    19 abril, 2012 @ 1:56 PM

    No, doesn’t work. Whatever I try to do – I always get
    There are total 0 images found
    There are total 0 images used
    There are total 0 not used images

    Is there anything else that can be done?

    Responder
    19 abril, 2012 @ 6:33 PM

    Same as A.H , on the site whre I know for sure that I have at least 3 000 not used photos (big connercial site) plugin reporting total of 0 unused / found. I am chmoding folder uploads now, to 777, maybe will help.

    Responder
      nicearma
      19 abril, 2012 @ 7:15 PM

      @vladimir Don’t do that, the plugin before was working scaning the dir, but i change that, and now the plugin take the information from the database only, i’m working to put the 2 logic together.
      @vladimir and @A.H But is weird because like i said, at this moment the plugin take the information from the database only, if you want we can speak for take a look to the database and the site, but you have to send me information like user and password or maybe send me one backup of your site withe de database for do test in my computer, but like i said only if you want, if you want please do that, let me know(don’t put your information here, is for send you an email for speak better)

    21 abril, 2012 @ 1:25 AM

    I’ve tried it lots of diff. way – no, doesn’t want to work.
    Here’s my screenshot http://imageshack.us/photo/my-images/99/dnuiscreenshot.png

    Responder
      nicearma
      21 abril, 2012 @ 1:16 PM

      I think know will work fine, i was a sentence in the query sql(i did only one mistake, but that was enough)
      the problem was in this line

      $last= ‘ ORDER BY `wp_postmeta`.`meta_id`’; (could only work if the data base was with “wp_” so i change to generic query)

      $last= ‘ ORDER BY `’ . $table_prefix . ‘postmeta`.`meta_id`’;

      that is why dint work with multisite to, please let me know if work!

    22 abril, 2012 @ 12:17 PM

    It seems to finally start working, thanx a lot. But I’d also recommend make the results appear in different colors, as disabled checkboxes are not so obvious. So I’d recommend that images that cannot be deleted be shown in red colors and those that can be removed shown in green.

    Responder
    22 abril, 2012 @ 10:03 PM

    Hey, somehow its working! GREAT RESULTS ! One of sites had 7611 photos on ftp, and 150.55 Mb size. After cleaning – 1543 photos and 51.55 Mb size. GREAT! Thank you so much man.

    Regard and big props

    Responder
    26 abril, 2012 @ 6:18 AM

    No, I was wrong – it still doesn’t work. It detects all child attachments and gives me an option to delete them, but when I select images to be removed and press button delete it says “This file appears not exist, that is why the plugin update the database”. But when I connect via FTP and go to that folder I still see that image EXISTS, plugin just fails to delete them.
    I can make screenshots and mail them to you, if you need more details.

    Responder
      nicearma
      27 abril, 2012 @ 7:46 PM

      Please try do this
      1 – Make a empty post and Upload one image
      2 – Go to the plugin (DNUI) and search the image upload
      3 – Try to see one of the image child(the version imageAAAxYYY) in the server with the link View (don’t close the window after)
      4 – Delete one of the image child(the version imageAAAxYYY)
      5 – Try to reload the window make in the step 3 and also in the server with your ftp program

      If in the step 3 you can’t see the image, the plugin have problem with the route, and that is why i s i have that problem in this blog with the new image, because now i use in this blog one plugin of amazon s3, so the route is out of the server.

      If you can see in the step 3 the image, go to the step 4, if in the first time came with the massage “This file appears not exist, that is why the plugin update the database” is rare, because is use the same route for see the image (only think this can happen if step 3 fail).

      If the step 4 says image deleted, please go to the step 5, if reload and you see the image. wait some time, because sometime take time to the server process the delete (why i dont know why, is something with the php function for delete file), if after sometime the image file exist is because the function php dont work fine and i have to see in the manual php how to fix that.

      Please let me know, which step fail, and i will put a function for search image who aren’t in refered in the database but exist in the server.

    Richard
    28 mayo, 2012 @ 11:59 PM

    Does not work. Deleted images that were in use. Thank god I backed up.

    Responder
      nicearma
      29 mayo, 2012 @ 6:19 AM

      Please read!!!!!!

      Make a save (Backup) of your database and your file (especially the uploadsfolder), because the code have to update the database and deletion of files that are irreversible,so if something goes wrong is better have a backup.
      Performs tests on any page other than your own default, but having the same characteristics, since I have not tested for compatibility with other plugin, so you can see if will work fine

    11 julio, 2012 @ 8:56 AM

    This is really very important plugin but needs more improvement. I manage to delete around 110MB unused image file from upload folder but still there are some unused images. I run 1000 query and got impressive result over 3000 unused images, i don’t know how it did search 3000 images with 1000 query search, i select all unused image and deleted it. Working great.

    Thanks for your effort on this plugin.

    Responder
    js
    16 julio, 2012 @ 10:33 PM

    I ran this my test site and boy I’m glad I did. It deleted all of the images I’m using. I had a feeling that there would be an issue because I use another plugin that puts the images in a non-standard location.

    What I’d like to see is a plugin that scans all of the html and databases for image references and then deletes the image files that are not referenced anywhere in the code. I’ll keep looking, but thank you for your effort.

    Responder
    basti
    17 julio, 2012 @ 11:28 AM

    I’ve used this plugin and it works great. Thanks for all the efforts!

    I realized that the “Select All” button just deletes the unused “son” images related to the father, but not the unused father images. Why is this? I still have several thousands unused father images and now I need to click all of them by hand. Is there a way around this?

    Thanks again! Great plugin and it works much better then most of the others around there – especially with large image collections like my blog!

    Responder
    21 julio, 2012 @ 5:21 AM

    Hi Nicearma
    I really liked the idea of this plugin and finally got the time to try it myself today. I know for sure that there is a lot of images on my server in different versions that are not used on my blog.
    Unfortunately I ran in to some issues. The plugin is also deleting images that are in fact used on my blog (Good thing I had a fresh backup). I noticed that it deleted both image on my front page and images from galleries. I don’t know if it has something to do with my theme.

    My blog is running with these versions:
    DNUI: 0.8.2
    Wordpress: 3.4.1
    Arras Theme: 1.5.1.2

    Responder
  • Pingback: Finding & Deleting Unused Image Files In Your Media Library

  • 7 octubre, 2012 @ 10:40 AM

    A recommendation to improve this plug-in is to have it validate if the image is selected as a featured image in a post. I am finding that every image on my site is coming back as erasable.

    Love the plug-in idea, but it falls short in identifying the correct images to show as erasable.

    Responder
    konuhov
    25 octubre, 2014 @ 7:50 AM

    Hi! Not work with wp 3.5 🙁 Please, fix it! All buttons is not active

    Responder
      nicearma
      25 octubre, 2014 @ 8:17 AM

      Hello, why you use wp 3.5? you have to update always the you wp site, if you see 90% of the updates is for security fixed, i really dont think so that i will have the time to make the plugin compatible with old version, only with news one, sorry i dont have the time.

    Tupic Farhad
    2 marzo, 2016 @ 5:37 PM

    Hi, I just bought the pro plugin, its not deleting the images. i get an angularjs error
    I am using the latest version of wordpress
    Error: [$resource:badcfg] http://errors.angularjs.org/1.4.8/$resource/badcfg?p0=deleteByIdAndSize&p1=object&p2=array&p3=POST&p4=%2FWP%2Fwp-admin%2Fadmin-ajax.php

    at Error (native)

    at http://www.*mydomain*.nl/WP/wp-content/plugins/dnui_pro/js/external/angular.min.js?ver=4.4.2:6:416

    Responder
      nicearma
      3 marzo, 2016 @ 8:01 AM

      Hello i send you a private message to your email

      nicearma
      7 marzo, 2016 @ 7:45 AM

      Hello again, i updated the pro version, normally you can download it 🙂

    Deja un comentario

    Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *


    *