Home » Php » php – Call to undefined function imagecreatefromwebp inside wordpress

php – Call to undefined function imagecreatefromwebp inside wordpress

Posted by: admin February 25, 2020 Leave a comment

Questions:

I’m trying to make a wordpress plugin that downloads images. I’ve seen this problems that sometimes a file taken from web, despite having a jpg extension, is actually in webp format. So i made a simple test feature to see if an image is in webp format:

 if ($im = @imagecreatefromwebp($filename)) {
    imagejpeg($im, $filename.'.jpeg', 100);
 }

I’ve tested in a test file put on the same server where wordpress is, just to see if the conversion is made and indeed it works.

Then i’ve put the same code inside the wordpress plugin but i get:

 Call to undefined function imagecreatefromwebp()

How is it possible? The server is the same, the plugin it’s just one folder away from the test file. The test file outside wordpress works, inside worpress the function doesn’t exists. Is wordpress disabling some of basic php functions?

How to&Answers: