webp-express icon indicating copy to clipboard operation
webp-express copied to clipboard

Convert image in theme via php

Open xpatrykk opened this issue 4 years ago • 3 comments

Hello, there is any method to convert uploaded file via php? I want use that method in my plugin. Many thanks for great plugin :)

xpatrykk avatar Jun 20 '20 10:06 xpatrykk

1+

mohamedsalehamin avatar May 07 '21 01:05 mohamedsalehamin

I noticed that there is a function webPExpressAlterHtml(), but it seems that the file this function is in is never loaded because when I tried to use it I got a fatal function does not exist error.

Hube2 avatar May 07 '21 11:05 Hube2

You could do: WebPExpress\Convert::convertFile($absolutePathToSourceFile). Make sure to wrap it in a try..catch statement.

The function takes other arguments. You find the code in webp-express/lib/classes/Convert.php

rosell-dk avatar May 07 '21 11:05 rosell-dk