Support » Plugin: Media File Renamer » Warning: Invalid argument supplied for foreach() …

  • Hello,

    I am having this error each time I try to rename a file:

    Warning: Invalid argument supplied for foreach() in /web/htdocs/ on line 571

    Warning: Invalid argument supplied for foreach() in /web/htdocs/ on line 643

    Has it anything to do with the fact that there are one original file and its resized one with the same title and alt tags in the same folder?

    thanks for the support

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Jordy Meow


    Not sure but it seems it’s crashing every time the plugin tries to use the WP’s metadata for that image.

    Can you change:

    foreach ( $meta['sizes'] as $size => $meta_size ) {


    if ( $meta['sizes'] )
    foreach ( $meta['sizes'] as $size => $meta_size ) {

    There should be two lines such as this one in the media-file-renamer.php file. Tell me if everything works better and as expected.

    I made the changes (thank you for support). I am still ongoing with the website editing, but within tomorrow for sure I will need to rename some files and I’ll let you know.

    PS. When it happens the problem, normally the files is renamed, yet the links to the images are broken and I need to edit them manually.

    Plugin Author Jordy Meow


    Yeah if the plugin crashes in the middle of an operation what you mentioned in the PS might happen…

    Please test the plugin again with this change and tell me if it is better.

    Hi Jordy,

    It is better, I don’t know, I have noticed that the error is not showing anymore, though the links are not updated. Any idea / debug?

    Plugin Author Jordy Meow


    Actually what kind of links are you talking about? Which ones?

    for example, I edit a picture title from “picturename” to “picturename 120×98”
    At this point the plugin flag the file as possible candidate to be renamed and so I click on “Rename 1 Flagged Media” button.
    The process go thru without errors

    Afterwards, the plugin Broken Links Checker pop up a message in Dashboard, warning me that there are 1 (or more, according to how many media were flagged), broken links to the just renamed media.

    So, the filename has changed, but the link to the original file in the database wasn’t changed accordingly, I have to do manually every time.

    Plugin Author Jordy Meow


    I understand the process, but where exactly is the file not properly renamed? In a post?

    Ok I have some news, it seems there is a problem with the plugin and “broken link checker” plugin (BLC).

    The files are all renamed properly and the links seems updated, just I don’t know why the plugin BLC detect they are broken.

    This plugin has a link on the dashboard with leads to the list of broken links found, if clicking on one of this link it actually cannot find the image, in fact the image has been renamed, the links in the post/pages updated, but maybe there is another table somewhere in the database which is not updated as well?

    Plugin Author Jordy Meow


    I am not sure of this plugin works but it seems it uses some kind of internal cache. I am using this plugin as well on a few of my websites but I didn’t notice anything special, it works well with my plugin.

    Can you ask to the developer of that plugin? He will definitely have an idea 🙂

    I have renamed some pictures and then after the error appeared, I downloaded the database and search for the old link, which show up here and there thought the DB, some links are updated, some links not, this is what the other plugin detects. How do you replace the links? Or as you say, should I leave the error up to see if it’s a cache problem?

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Warning: Invalid argument supplied for foreach() …’ is closed to new replies.