Support » Plugins and Hacks » Undefined index error

Undefined index error

  • Hi Justin.

    With WP_DEBUG set to true, I get the following error when calling get_the_image with these parameters:

    $img = get_the_image( array(
        'post_id' => $post->ID,
        'size' => $size,
        'attachment' => true,
        'image_scan' => true,
        'echo' => false,
        'format' => 'array',
        'default' => $default
    ) );
    Notice: Undefined index: src in [...]/wp-content/plugins/get-the-image/get-the-image.php on line 181

    The notice complains about this line:

    $out['url'] = $out['src']; // @deprecated 0.5 Use 'src' instead of 'url'.

    Verifying the attribution like this solved my problem:

    $out['url'] = !empty( $out['src'] ) ? $out['src'] : false; // @deprecated 0.5 Use 'src' instead of 'url'.


  • The topic ‘Undefined index error’ is closed to new replies.