Received a new error after updating php to version 7.1 Here's what he writes:

Warning: strpos(): Empty needle in .../wp-includes/media.php on line 1147

Here's what's on this line:

if ( ! $src_matched && false !== strpos( $image_src, $dirname . $image['file'] ) ) {

Full code:

// If the file name is part of the `src`, we've confirmed a match.
if ( ! $src_matched && false !== strpos( $image_src, $dirname . $image['file'] ) ) {
    $src_matched = $is_src = true;

How to fix this error?

  • Do you still get the error if you disable all plugins & switch to a standard theme? – kero Jul 15 '17 at 16:57
  • The 'needle' according to the official docs is the second parameter, it would appear that sometimes those values are empty. Since this is Core WordPress code, we'll need to know what is calling that code, so a stack trace will be needed. However, a WP Core Trac ticket should also be created – Tom J Nowell Jul 15 '17 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.