23

So I'm trying to add .webp image support for a WordPress site, which is run on IIS.

Now the image exists on the server and the file name is correct but when I try to load the image via URL address in the browser I get the 404 error.

404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

Anyone know how I might resolve this issue?

I tried added <add extension=".webp" policy="CacheUntilChange" kernelCachePolicy="DontCache" /> but this doesn't work as it's to do with caching.

Is there somewhere were I can allow access to certain file types?

Do I maybe need to allow the filetype through the firewall?

I'm still new to working with IIS so I'm a little lost.

Cheers

krlzlx
  • 5,752
  • 14
  • 47
  • 55
Web Dev Guy
  • 1,693
  • 3
  • 18
  • 42

4 Answers4

43

You'll need to add this config to your webconfig file:

<configuration> 
    <system.webServer> 
        <staticContent> 
            <mimeMap fileExtension=".webp" mimeType="image/webp" /> 
        </staticContent> 
    </system.webServer> 
</configuration>
isherwood
  • 58,414
  • 16
  • 114
  • 157
Mahnian
  • 496
  • 3
  • 8
  • Note, if I upload this to the ACTUAL IIS server (not just the IIS Express server I'm running via Visual Studio) the website breaks. It works great for debugging and testing, but not for production. For production IIS, use @Macster's solution below. – yougotiger Jun 08 '21 at 19:08
24

The fastest solution with less headache is to just add the file extension .webp to the mime types as below:

  1. Select website from IIS Manager: 1. select website from IIS Manager

  2. Add file extension to Mime Types: 2. add file extension to Mime Types

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Macster
  • 341
  • 2
  • 3
  • 3
    The correct MIME type for .webp file is "image/webp", not "video/webp". reference: [link](https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types) – Hamedb Aug 22 '22 at 06:55
5

Ok figured it out.

I had to allow the mime type in iis manager.

https://technet.microsoft.com/en-us/library/cc725608(v=ws.10).aspx

Web Dev Guy
  • 1,693
  • 3
  • 18
  • 42
2

Webp images are not showing, when you run or debug the application. Especially in IIS Express and IIS. For IIS we can go the Mime type in the app config as mentioned. But for the IIS express, even though you add in app.config, it does not show up. Just follow this procedure to resolve this issue.

  1. Open the IIS Express Dialog using the icon from System tray. Check image. Open IIS Express from system tray

  2. In the dialog box, select the website. You can see the related details in the below section. IIS Express dialog box

  3. See the config path, it varies for every app or site you develop. Click that link and you can get the config file opened in your VS studio. Now add the webp mime extension code along with other image types. save the file and close it.

Now, you are able to view the webp images in local browsing in debug mode. Problem resolved.