
Adding new mime type (WebP) in WordPress
Recently while finishing up a site with a few high quality images that needs to be transparent, I needed it to be small (100kB is acceptable for me), because I dont want people to load 10MB for a site. I remembered that there’s a new (well, not new but I just didnt use it as often as I should) image format, WebP. As of now, WordPress 4.5.3, it does not support webp as its mime type, so if you tried to upload it, you’ll get a message or something about it not being supported.
Since my image editing program cant save in WebP (maybe it could, but have not bothered to search further). I converted my PNG to WebP at convertio.co. From 436KB to 44KB!
Just add the following code into your template’s functions.php (In the backend, Appearance -> Editor -> functions.php)
1 2 3 4 5 6 7 8 |
function webp_upload_mimes( $existing_mimes ) { // add webp to the list of mime types $existing_mimes['webp'] = 'image/webp'; // return the array back to the function with our added mime type return $existing_mimes; } add_filter( 'mime_types', 'webp_upload_mimes' ); |
Yeay for small image size!
Hello, I found this information very helpful in difficult moment. Looking forward for more awesome updates.
Thanks a lot Mkhairul. Before appying this trick, I was getting an error while uploading webp format images, after adding this snippet through Code Snippet plugin. my problem successfully solved with in second.
Sincerely,
Gulshan
I am also searching for this finally got here . thnq mkhairul for providing valuable info abou this
What a nice find! Thanks for sharing this. Hopefully Photoshop CC will support this format soon