The YetaWF.Core.ImageHttpHandler assembly/package processes HTTP requests to serve images stored in YetaWF's data files and databases. The HTTP handler is used in the IIS pipeline with ASP.NET 4 and as middleware with ASP.NET Core.
The ImageHttpHandler HTTP handler only serves images stored in data files and databases. It is not used to serve static images, which are referenced directly by URL.
URLs /FileHndlr.image are processed and have the following format:
|Type||Defines the image type which must match a registered image handler. The YetaWF.Core.Image.ImageSupport.AddHandler method is used to register an image handler.|
|Location||This is typically used to define the location of the image. This argument is processed by the registered image handler and is image handler specific.|
|Name||This is typically used to define the name of the image. This argument is processed by the registered image handler and is image handler specific.|
|Width||Optional. Defines the width of the rendered image. This can be used to resize the image server-side. If not specified the natural image size is used.|
|Height||Optional. Defines the height of the rendered image. This can be used to resize the image server-side. If not specified the natural image size is used.|
|Percent||Optional. Defines the size of the rendered image in percent. This can be used to resize the image server-side. If not specified the natural image size is used. Example: 200% doubles the size of the image, 50% shrinks the image size by 50%.|
|Stretch||The default is False. If set to 0 or False, the image will be resized proportionally. If set to 1 or True the image is sized given the specified height/width which may result in non-proportional resizing, changing the aspect ratio.|
If an image doesn't exist and cannot be retrieved by the registered image handler, a default image is shown.
Only file types defined in mimeSettings.json with the ImageType: true attribute can be served by the HTTP image handler.
If the requested image is stored in a file in the local file system and an image file with the .webp-gen extension is available at the same location, it is served instead, provided the requestor has indicated support for the WEBP image format (HTTP Accept header). Image files with the .webp-gen extension are automatically created as part of the build pipeline.
The HTTP image handler adds ETag and Last-Modified headers for caching support and honors the If-None-Match header of incoming requests. The HTTP handler honors the settings Application.P.StaticFiles.Duration (AppSettings.json) which determines caching duration.
The HTTP image handler is implemented by the YetaWF.Core.HttpHandler.ImageHttpHandler class.
An application can add any number of image types which are used by the /FileHndlr.image Type=imageType argument. The YetaWF.Core.Image.ImageSupport.AddHandler method is used to register an image handler. By implementing the desired access methods, the ImageHttpHandler HTTP handler will retrieve the image.
See Also YetaWF.Core