O zaman replace kodunuzu
if (!strpos($string, "webp")) {

}

içine alın ki stringte webp varsa onu replace etmesin hocam. (doğru anladıysam konuyu)