Hi,
A notice in admin with debug enabled:
Notice: Array to string conversion in /var/www/mysite/wp-content/plugins/wp-media-cleaner/wpmc_settings.php
Scanner doesn’t work, stays on “Read medias…”
Worked with WP 4.2.4, but seems to be ended with WP 4.3.
Regards.
I am keep on getting ‘No Task’ popup error when i try to start the Scan.
On seeing this error, i upgraded to PRO hoping that it would go, but it is still the same.
Whats the issue here ?
]]>I just installed this plugin and am trying to use it for the first time. I get this error message several times on the plugin dashboard
Table ‘wordpress.wptable_wpmcleaner’ doesn’t exist
It seems like it didn;t install properly. I’ve tried uninstalling and reinstalling. When I activate the plugin I get this error:
The plugin generated 899 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.
Any advice would be appreciated!
]]>Hi Jordy,
Just installed your plugin hit the scan button and see >PLEASE WAIT
Nothing happens after i waited for 20 mins.
then i get a 502 time out gateway error.
Any ideas please
Is there a way to scan an entire multi site network? We have 30 sites running and I would love to be able to do a single scan instead of 30.
]]>Upgraded to 2.4.0 and attempted to scan – the process freezes at 14/719 (2%). Tried to reset, uninstall, reinstall – same thing.
Downgraded to 2.2.6 – scan goes all the way to 100% without any problem.
]]>If you have any issues, requests, questions, please use GitHub from now:
https://github.com/tigroumeow/wp-media-cleaner/issues.
You are also welcome to participate in the coding and enhancement of the project ?? Don’t worry however, the last stable version of the plugin will be always on the WordPress repository.
I will personally not read the messages posted here and the chance that another user might help you is very low. Therefore, I will close the current opened threads. Feel free to re-open them on GitHub but please try the last version of the plugin before doing this. Thanks ??
]]>Hi there,
just installed the plugin and ran a scan. 3 pics i only use in a metaslider slideshow were detected as not in use. I hope you can update the plugin to check inside sliders as well ….? ??
Thanks
Alex
I just spent a bunch of time sort of “overhauling” wp-media-cleaner’s scanning and detection.
I wrote a plugin recently for indexing PDFs and for the site I wrote it for I only wanted to index PDFs that were deemed as being attached. So I wrote a bunch of detection methods for finding files within content, shortcode, widgets, etc. I found wp-media-cleaner often missed some of this content so I took the time to apply what I had done with my plugin to yours. I also found and fixed a couple other issues along the way.
Besides finding content that it was reported as unused, the other big issue I wanted to address was most of your matches were using partial file names. e.g. If I file was “uploads/path/image.png”, in a few places you were only searching “image.png.” That would obviously match that filename if it were in any path on the server, or worse, even a file linked so an external host. I came up with the following regex for my plugin and implemented that here:
$regex = addcslashes('=[\'"](?:(?:http(?:s)?\\:)?//'.preg_quote($parsedURL['host']).')?(?:'.preg_quote($parsedURL['path']).'/)'.$regex_match_file.'(?:\\?[^\'"]*)*[\'"]', '/');
Using that regex, the code will match all of the following:
href=”https://www.host.com/uploads/path/image.png”
href=”https://www.host.com/uploads/path/image.png?somevar=1″
href=’https://www.host.com/uploads/path/image.png’
href=”//www.host.com/uploads/path/image.png”
href=”/uploads/path/image.png”
src=”/uploads/path/image.png”
But it would not match…
href=”https://www.someotherhost.com/uploads/path/image.png”
href=”https://www.host.com/uploads/other_path/path/image.png”
The regex is adapted for matching against metal fields which wont be wrapped in quotes:
$regex = addcslashes('(?:(?:(?:http(?:s)?\\:)?//'.preg_quote($parsedURL['host']).')?(?:'.preg_quote($parsedURL['path']).'/)|^)'.$regex_match_file, '/');
Which will match…
https://www.host.com/uploads/path/image.png
https://www.host.com/uploads/path/image.png
/uploads/path/image.png
path/image.png
etc.
Here is a file compare. https://www.diffnow.com/?report=58be2
And here is the file: https://www.dropbox.com/s/gkfdud7jye2zhiz/wp-media-cleaner.php?dl=0
function wpmc_wp_ajax_wpmc_scan_do
102: I can’t stand line like this without braces ?? …but I really the only reason I put them in was so I can add some debugging lines while I worked.
function wpmc_get_galleries_images
172: 12 hours seemed rather long for the transient
function wpmc_wp_ajax_wpmc_scan
183: This is my new transient for the post_content with shortcode extracted
193-203: This set of code eliminates some double scanning the process was doing. I didn’t see a reason so scan files that were also going to be scanned from the media side as well. So I first store the IDs and Paths in an array (one of which gets passed back for the json) and the then they are used to eliminated from the $files array media that will be scanned anyway.
205-218: I also felt like there is no need to scan all of the alternate image sizes as long as the source file existed in the database.
function wpmc_delete
318: Just an extra check to make sure we aren’t deleting a local the file the actually has a media db entry. Earlier when I was testing this happened. Could have been caused by something else but I figured worth leaving in.
function wpmc_check_is_ignore
440: From my understanding this is the way to properly escape-like in wordpress. Also, you didn’t have deleted = 0 in the query before. So it would ignore a new file that had the same path as an old one that was trashed.
function wpmc_check_in_gallery
475-482: added wpmc_clean_uploaded_filename here so we can pass the full path and get better matching
function wpmc_check_db_has_featured
487: wpmc_check_db_has_featured — There is no need for wpmc_check_db_has_featured. I realized this after modifying. I lef the code there for your review, but wpmc_check_db_has_meta probably isn’t any less expensive and covers the same thing.
function wpmc_check_db_has_meta
503: Along with passing the full path into this function I am regexing the match, making sure it’s not matching against it’s own meta_data by also passing in the attachment_id (when available) and also added meta_value = attachment_id to catch some other forms of using featured images and some other plugins.
function wpmc_check_db_has_content
519: So this is where the motherload of changes is… So the first thing I do is query post content via the more stricter regex match. If the file is found then great. Move on. If not, then we pull all posts that contain all of the applicable shortcode, loop through them processing the do_shortcode, and then store the results in a transient. I do the same thing with all active widgets and store it along with the post content. Once the transient is stored, we then loop through it checking for matches with the regex.
function wpmc_find_attachment_id_by_file
598: Added function. Name describes it all. Used to get an attachment ID from a file path.
function wpmc_check_file
611: This is a fix. You were doing strip slashes for $filepath but the $path was being used in other places. Most importantly storing it in your issues table. This was breaking detection for files with single quotes in their name.
638: First we check the ignore table. If it’s there just quit.
640: Get the attachment id (used later) and then determine by the extension and with another bit a regex if this is an alternate image size. If the source file does not have a media id or the source file does not exist then mark it as “no media.” Otherwise I feel there is no reason to bother checking each of these individually. When the source file itself is scanned we will check the alternate image sizes then. NOTE: This is kind of irrelevant now because I coded this before I made the modifications to wpmc_wp_ajax_wpmc_scan where I eliminate the image sizes from the scanning arrays. So in theory, this should never happen anyway now.
655: This is another fix. I added wpmc_check_db_has_meta here and moved wpmc_check_db_has_content (in order of most expensive to least). You had wpmc_check_db_has_meta after this and I couldn’t quite figure out why as by doing so a file would never be marked as “NO_CONTENT” since it wouldn’t get by this and to the insert statement without being marked as “NO_MEDIA”.
666: To check alternate image sizes of files I use the glob function. I think maybe this should may be employed into check_media in addition to or instead of using wpmc_get_image_sizes. I didn’t find a reason to for now as all of my images checked out. But something to consider.
function wpmc_check_media
740 (& 776): Check to see if the file exists to check for orphaned media. If it doesn’t exist I add a new issue “ORPHAN_MEDIA”.
747 & 766: Add wpmc_check_db_has_meta to this and also move wpmc_check_db_has_content last for speed.
function echo_issue
821: Added new issue
function wpmc_screen
813: Another fix: weren’t htmlspecialchar escaping the file itself. Only the path before it. Broke files with single quotes in them.
Once you click ignore for a file in the trash, the number of ignored files increases accordingly, but you can’t see your file there. It’s not available among the media files either.
]]>Hi,
Be careful, background images defined in CSS within a child-theme styles.css file are reported as unused!
]]>Thank you for your plug-in.
Unfortunately I deleted a few too many files. I have retrieved the media files from my backup but I now want to return my database files etc back to the original version from my backup also. Can you tell me which files get changed during the deletion process?
Hi!
I′ve done all the works.
– Scanned and recognized images
– Created LR ID′s for all photos i LR
– Manually linked those images not recognized automatiacally by plugin
– THEN: used images in posts still uses old images
– What is not working here? I have some 600 images in use on my website, and would expect the plugin to have all image-links in the entire website to be updated using the newly synced images.
Am I missing something here?
Any suggestions is appreciated
??
]]>Since you are single quoting image tags in wpmc_screen, you need to “htmlspecialchars” for file with singe quotes in the names–
if ( $issue->deleted == 0 ) {
if ( $issue->type == 0 ) {
// FILE
$upload_dir = wp_upload_dir();
echo "<img style='max-width: 48px; max-height: 48px;' src='" . htmlspecialchars($upload_dir['baseurl'], ENT_QUOTES) . '/' . $issue->path . "' />";
}
else {
// MEDIA
$attachmentsrc = wp_get_attachment_image_src( $issue->postId, 'thumbnail' );
echo "<img style='max-width: 48px; max-height: 48px;' src='" . htmlspecialchars($attachmentsrc[0], ENT_QUOTES) . "' />";
}
}
]]>
Need to add “sites” to–
$wpmc_exclude_dir = array( “.”, “..”, “wpmc-trash”, “.htaccess”, “ptetmp”, “profiles”, “sites” );
in wp-media-cleaner.php. Or if you wanted to get technical, add a “if multisite” to it. Without it, when doing a scan on the root site it will scan subsite’s filesystem.
]]>My media gallery says i have 2,800 files wp media cleaner is still scanning, three hours no and shows 36310/121717 (30%)
I have set it not to scan the media just uploads.
to be able to pause and look at the results bit by bit would be good.
it also shows sql files and json files as media files??
]]>I have mailpoet (wysija) installed on my site, and the plugin catches the wysija files as problems. Just wanted to let you know, and hoped this could be patched for future use. For now I’m just ignoring them ??
]]>Hi !
I’m using WP Media Cleaner and it works well on most of my websites but it doesn’t work with one with very big media data base.
There’s many images and it seems plugin crash or something. When I try to scan it says “Please wait…” and that’s all.
I tried to let it works many hours without results.
Any ideas ?
Hi,
I’d like to request a feature that allows us to filter out files based on certain criteria (perhaps using regular expressions to match file paths as well as file names).
This is because some plugins put files in the upload/ directory, and it gets confusing when these files get picked up by WP Media Cleaner.
Thanks
]]>The plugin reports files with non-ASCII characters in the file name as non used and deletes them if not manually ignored.
]]>Hi,
The scan result reports that there isn’t any unused image. I find this hard to believe.
So, I’d just like to know how this plugin detects unused images?
I am not sure if this affects the plugin, but I am using a plugin called EWWW Image Optimizer (https://www.ads-software.com/support/plugin/ewww-image-optimizer) the purpose of which is to compress uploaded images.
I believe that EWWW Image Optimizer stores all images in the database in order to keep information about the compression results.
Is it possible that the fact the database has references to all images, confuse WP Media Cleaner such that it thinks that all images are used/referenced?
Thanks
]]>Like this
https://selftrips.ru/wp-content/uploads/2013/07/P10600061.jpg
but from main page WP Media Cleaner
I have tried to use your plugin but it has never completed a scan. It got to a maximum of 77% and just will not advance from there. The last scan stopped at 12%. What could be responsible for this? Thank you.
]]>Hi,
The plugin flat out wouldn’t work for me with Notices enabled, as the initial json returned data from the Scan start is polluted with a PHP Notice.
<b>Notice</b>: Undefined variable: galleries_images in <b>D:\projects\victoria-mason\site\wp-content\plugins\wp-media-cleaner\wp-media-cleaner.php</b> on line <b>156</b>
The line in question:
if ( !$galleries_images ) {
That reads fine to me, if it were javascript, but PHP doesn’t like it so much.
if ( !isset($galleries_images) ) {
cleans up the response and lets things work as expected.
]]>Why we need options page? Maybe add that two checkbox on scaning page and delete options page at all?
And it seams not working. I check one checkbox “The Media Library will be scanned.”, but plugin scan all – midia and files/ Is it normal, i think not.
]]>Plugin don’t delete their options on uninstall. wpmc_basics option is in wp_options table after complately delete plugin (uninstall).
And pugin don’t delete ‘wpmc-trash’ folder on uninstall.
I think after uninstall plugin must delete their options and trash folder too.
Thanks for the plugin!
]]>Hi there!
First of all: I really like the idea of your plugin and it seems to work pretty good.
However, I’m using 2 plugins that handle images:
– The BWS photo gallery plugin
– Dynamic headers (to have random header images)
I kind of expected this to happen. As always I made a backup before trying your plugin. I saw some people complaining about your plugin wrongfully deleting images, seems to me that it was their own mistake.
Anyway… any ideas on how to fix this? I’m not exactly sure how these plugins put their data into the database. Maybe a setting to make exceptions on certain meta_key values could help?
I’m going to try to find my own solution, thought I’d just report this.
Kind regards,
Niels
]]>Hi, I am running wordpress 3.5.1 and I have tried to use the plugin but it keeps saying please wait and nothing happens.
I am waiting to hear back from my web developer to see if I can upgrade to the latest version of wordpress without breaking my site.
In the mean time is there something else I can do to make it work?
My site is https://www.christinefrancis.com
Hi there,
Your Plugin looks very interesting! Any chance you will introduce support for the Advanced Custom Fields Plugin in a future release?
I don’t make use of the WP core attachment functionality anymore, because in my installs I want to use the same images in different locations.
It would be amazing to still be able to find unused items programmatically…
]]>Something went wrong with a few Woocommerce imports, so I have around 25 GB of images!
Most of them aren’t used, so I hope they can be removed with WP Media Cleaner.
I have installed the plugin, but after clicking Scan, it’s been saying “Please wait…” for 2+ hours.
Can the plugin handle so many images?
Thanks,
Mads