Support » Plugin: Media Cleaner - Clean & Optimize Space » Got error in combination with ACF Pro

  • Resolved LienekeKoenen


    Everything works fine with all plugin’s off, but when I activate the plugin ACF Pro and try to run a scan, I get a couple of PHP errors:

    AH01071: Got error ‘PHP message: PHP Warning: Illegal string offset ‘type’ in wp-content/plugins/media-cleaner/scan.php on line 129\nPHP message: PHP Warning: Illegal string offset ‘type’ in wp-content/plugins/media-cleaner/scan.php on line 129\nPHP message: PHP Fatal error: Uncaught Error: Cannot use object of type WP_Post as array in wp-content/plugins/media-cleaner/scan.php:129\nStack trace:\n#0 wp-includes/class-wp-hook.php(286): MeowApps_WPMC_Scan->scan_postmeta_acf(’40’)\n#1 wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)\n#2 wp-includes/plugin.php(453): WP_Hook->do_action(Array)\n#3 wp-content/plugins/media-cleaner/core.php(300): do_action(‘wpmc_scan_postm…’, ’40’)\n#4 wp-includes/class-wp-hook.php(286): Meow_WPMC_Core->wp_ajax_wpmc_prepare_do(”)\n#5 wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(”, Array)\n#6 wp-includes/plugin.php(453): WP_Hook…\n’, referer: /wp-admin/upload.php?page=media-cleaner

    WP 4.9.6
    ACF PRO 5.6.10
    Media Cleaner 4.8.0

    I assume I need to have ACF activated to make sure I don’t trow away images that are attached to ACF fields?

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



    Yes, it seems ACF released a new update and my plugin has an issue with it now. It will, unfortunately, take a bit of time and research to fix it, but I would like to do it by the end of next week. I’ll try my best 🙂

    Hi Jordy,

    I got it working:

    Change line 129 in scan.php:
    if ( $subfield['type'] == 'image' ) {
    if (is_array($subfield) && $subfield['type'] == 'image') {

    unfortunately it doesn’t solve the problem 😀 Gotta find those images in the array, else it won’t see that the image is attached to the repeater field. I’ll see if I can find out where it’s stored. 🙂

    Plugin Author Jordy Meow


    The problem is that if $subfield is an array, then it can’t be an object but the point of the check is to check it as an object.

    Basically, this change means removing a piece of my code, and losing a part of the detection I do in ACF 🙂 It makes the issue goes off the radar.

    Plugin Author Jordy Meow


    That would be awesome if you could find it. I am off for a few days now, but please contact me directly if you are willing to search more:

    The information for the images is no longer stored in $field['value']. The information about the fieldtype is in $field['sub_fields'], here you can find if the singular field is ‘type’ image. But since you have to go inside the array of subfields to get the type, you are outside of the parent repeater field. The value’s for the images are stored in $field['value'] but not with the key ‘ID’ or ‘URL’. The key is the name of the field, which is also stored in the ‘sub_fields’.

    I wrote some code, but it’s not working. But at least you can see what not to do xD

    // ACF Repeater
    if ( $field['type'] == 'repeater' ) {
        if ( !empty( $field['sub_fields'] ) ) {
            foreach ($field['sub_fields'] as $subfields){
                if($subfields['type'] == 'image'){
                    $parent = get_field_object($subfields['parent']);
                    $name = $subfields['name'];
                    foreach($parent['value'] as $value){
                        $image = $value[$name];
                                array_push( $postmeta_images_acf_ids, $image['id'] );
                            else if(is_numeric($image)){
                                array_push( $postmeta_images_acf_ids, $image );
                                array_push( $postmeta_images_acf_urls, $this->core->wpmc_clean_url( $image ) );
    Plugin Author Jordy Meow


    I am currently asking ACF for a license for the Pro version so that I can support it. Don’t hesitate to contact them to tell them to help the developer at Meow Apps 🙂

    Plugin Author Jordy Meow


    Hi @lienekekoenen. I could get the new version of ACF Pro thanks to the developer, but we couldn’t reproduce the bug you are experiencing. Could you contact us directly through 🙂

    @tigroumeow I’m having the same issue. Just installed the plugin on my local to give it a whirl and it threw the Illegal Offset warning a whole bunch and then finally crapped out w/ the fatal error:

    [21-Jun-2018 19:34:03 UTC] PHP Warning:  Illegal string offset 'type' in /Applications/MAMP/htdocs/addisoncom/wp-content/plugins/media-cleaner/scan.php on line 129
    [21-Jun-2018 19:34:03 UTC] PHP Fatal error:  Uncaught Error: Cannot use object of type WP_Post as array in /Applications/MAMP/htdocs/addisoncom/wp-content/plugins/media-cleaner/scan.php:129
    Stack trace:
    #0 /Applications/MAMP/htdocs/addisoncom/wp-includes/class-wp-hook.php(286): MeowApps_WPMC_Scan->scan_postmeta_acf('551')
    #1 /Applications/MAMP/htdocs/addisoncom/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
    #2 /Applications/MAMP/htdocs/addisoncom/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
    #3 /Applications/MAMP/htdocs/addisoncom/wp-content/plugins/media-cleaner/core.php(300): do_action('wpmc_scan_postm...', '551')
    #4 /Applications/MAMP/htdocs/addisoncom/wp-includes/class-wp-hook.php(286): Meow_WPMC_Core->wp_ajax_wpmc_prepare_do('')
    #5 /Applications/MAMP/htdocs/addisoncom/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array)
    #6 /Applications/MAMP/htdocs/addisoncom/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
    #7 /Applications/MAMP/htdocs/addisoncom/wp-admin/admin-ajax.php(99): do_action('wp_aja in /Applications/MAMP/htdocs/addisoncom/wp-content/plugins/media-cleaner/scan.php on line 129

    WP version 4.9.6
    ACF Pro version 5.6.10

    Hello, @robmaurizi
    Could you share your actual ACF setup to help me reproduce the issue?
    You can export ACF’s field groups as PHP code from:

    Dashboard > Custom Fields > Tools > Export Field Groups > Generate PHP

    And if you are okay, paste the generated code to here, or email me (hello[at]
    That would be greatly helpful for us to figure out the cause of this issue and fix it.

    • This reply was modified 2 years, 6 months ago by amekusa.

    @amekusa- I just emailed you the ACF php defs.


    @robmaurizi Thank you! Got the code.
    Now I can investigate further. Please be patient until fix.

    Hi @lienekekoenen @robmaurizi
    Today, Media Cleaner has updated to 4.8.4.
    I think now the reported issue has been fixed.
    Please check it after you update Media Cleaner.
    And feel free to post anything you noticed on here.


    It took a while, I had to click on reset a couple times and turn my plugins on and off. But it works perfect now! Thanks!

    Plugin Author Jordy Meow


    We glad to hear that @lienekekoenen 🙂 Thank you!

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Got error in combination with ACF Pro’ is closed to new replies.