Custom Fields
Re-Envisioned
Support General Invalid argument supplied for foreach() in …/inc/fields/image.php on line 166

  • Creator
    Topic
  • #18150
    Resolved rikmulder
    Participant

    Hi there, after updating to Meta Box 5.2.6 i get the following error in my error logs for almost every page including images uploaded via custom field. In the front-end they show well though.

    PHP message: PHP Warning: Invalid argument supplied for foreach() in /var/www/XXX/wp-content/plugins/meta-box/inc/fields/image.php on line 166

    When I go back to Meta Box 5.2.4 everything works fine again. No error messages in the log files.

    I use ShortPixel Image Optimizer for optimizing the images. As far as I know this plugin only has effect on uploading images. The only difference I see is this line in the 5.2.6. version which causes the error:

    protected static function get_image_meta_data( $attachment_id ) {
        $metadata = wp_get_attachment_metadata( $attachment_id );
        $dir_url  = dirname( wp_get_attachment_url( $attachment_id ) );
    
        foreach ( $metadata['sizes'] as &$size ) {
            $size['url'] = "{$dir_url}/{$size['file']}";
        }
        return $metadata;
    }

    In 5.2.4 this line isn’t there at all. Any thoughts on how to fix this so i can use the newest version again?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #18159
    Anh Tran
    Keymaster

    Hi,

    I answered in the other topic. I think the problem is the same. Can you please check it?

    #18173
    bdthemes
    Participant

    same problem me too after updated to 5.2.6.

    <?php
    $ep_widget_icon = rwmb_meta( 'ep_widget_icon', 'type=image_advanced&size=standard' );
    foreach ( $ep_widget_icon as $widget_icon ) { 
    $ep_widget_icon_url = esc_url($widget_icon["full_url"]);
    }
    ?>
    <img src="<?php echo $ep_widget_icon_url; ?>" alt="" class="ep-widget-icon" bdt-svg>

    Warning: Invalid argument supplied for foreach() in wp-content\plugins\meta-box\inc\fields\image.php on line 166

    #18174
    Anh Tran
    Keymaster

    Hi guys, I’ve just push a fix for this. Can you check if that works for you? Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Newsletter

Subscribe to our newsletter to receive news and tutorials for Meta Box and WordPress.


grid gear info copy caret-up caret-down trash