WordPress.org

Ready to get started?Download WordPress

Forums

Media File Renamer
Warning: Invalid argument supplied for foreach() ... (11 posts)

  1. davidebabylonia
    Member
    Posted 5 months ago #

    Hello,

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

    Warning: Invalid argument supplied for foreach() in /web/htdocs/www.cookingwithpeachy.com/home/wordpress/wp-content/plugins/media-file-renamer/media-file-renamer.php on line 571

    Warning: Invalid argument supplied for foreach() in /web/htdocs/www.cookingwithpeachy.com/home/wordpress/wp-content/plugins/media-file-renamer/media-file-renamer.php 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
    Davide

    http://wordpress.org/plugins/media-file-renamer/

  2. Jordy Meow
    Member
    Plugin Author

    Posted 5 months ago #

    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 ) {

    To:

    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.

  3. davidebabylonia
    Member
    Posted 5 months ago #

    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.

  4. Jordy Meow
    Member
    Plugin Author

    Posted 5 months ago #

    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.

  5. davidebabylonia
    Member
    Posted 5 months ago #

    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?

  6. Jordy Meow
    Member
    Plugin Author

    Posted 5 months ago #

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

  7. davidebabylonia
    Member
    Posted 5 months ago #

    for example, I edit a picture title from "picturename" to "picturename 120x98"
    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.

  8. Jordy Meow
    Member
    Plugin Author

    Posted 5 months ago #

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

  9. davidebabylonia
    Member
    Posted 5 months ago #

    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?

  10. Jordy Meow
    Member
    Plugin Author

    Posted 5 months ago #

    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 :)

  11. davidebabylonia
    Member
    Posted 5 months ago #

    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?

Reply

You must log in to post.

About this Plugin

About this Topic