Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WEBP support doc #10282

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions docs/en/02_Developer_Guides/14_Files/06_Allowed_file_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,43 @@ SilverStripe\MimeValidator\MimeUploadValidator:
- 'text/plain'
- 'text/calendar'
```

## Adding new image types {#add-image-format}

Silverstripe CMS support JPEG, GIF, PNG and WebP image formats out of the box. Silverstripe CMS can be configured to support other less common image formats (e.g.: AVIF). For this to work, your version of PHP and of the [`intervention/image` library](https://intervention.io/) must support these alternative image formats.

For example, this snippet can be added to the configuration of older Silverstripe CMS projects to allow them to work with WebP images.

```yml
maxime-rainville marked this conversation as resolved.
Show resolved Hide resolved
---
Name: myproject-assetsfiletypes
After: '#assetsfiletypes'
---
SilverStripe\Assets\File:
file_types:
webp: 'WebP Image'
allowed_extensions:
- webp
app_categories:
image:
- webp
image/supported:
- webp
class_for_file_extension:
webp: SilverStripe\Assets\Image

SilverStripe\Assets\Storage\DBFile:
supported_images:
- image/webp

---
Name: myproject-mimevalidator
After: '#mimevalidator'
Only:
moduleexists: silverstripe/mimevalidator
---
SilverStripe\MimeValidator\MimeUploadValidator:
MimeTypes:
webp:
- image/webp
```
28 changes: 28 additions & 0 deletions docs/en/04_Changelogs/4.11.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [Regression test and Security audit](#audit)
- [Dropping support for PHP 7.3](#phpeol)
- [Features and enhancements](#features-and-enhancements)
- [Upload and use WebP images in the CMS](#webp)
- [Preview any DataObject in any admin section](#cms-preview)
- [Other features](#other-features)
- [Bugfixes](#bugfixes)
Expand All @@ -23,6 +24,33 @@ In accordance with our [PHP support policy](/Getting_Started/Server_Requirements

## Features and enhancements {#features-and-enhancements}

### Upload and use WebP images {#webp}

WebP is an alternative image format for displaying picture on websites. It provides generally better results in most use cases to JPEG and PNG.

Read [An image format for the Web](https://developers.google.com/speed/webp) for more information about WebP.

WebP has wide – but not universal – support across web browsers. Internet Explorer is the main browser that does not support WebP at this stage.

Read [Can I use WebP?](https://caniuse.com/webp) to see which browsers can render WebP images.

Until now, Silverstripe CMS would default to blocking content authors from uploading WebP images. Given that [Internet Explorer will be end-of-life in June 2022](https://blogs.windows.com/windowsexperience/2021/05/19/the-future-of-internet-explorer-on-windows-10-is-in-microsoft-edge/) and that its market share are now under 1% according to most surveys, we decided the time had come to enable WebP by default in the CMS.

Once your project is upgraded to Silverstripe Recipe CMS 4.11, your content authors will automatically be able to upload WebP images and add them to web pages. We recommend you have a conversation with your users about the pros and cons of WebP so they can make an informed decisions about when to use this image format.

If your website still caters to a significant number of visitors with browsers that do not support WebP, you can disable WebP image upload by adding this snippet to your YML config:
```yml
---
Name: myproject-assetsfiletypes
After: '#assetsfiletypes'
---
SilverStripe\Assets\File:
allowed_extensions:
webp: false
```

Read [Allowed file types](/Developer_Guides/Files/Allowed_file_types) in the Silverstripe CMS documentation for more information on how to enable or disable new image file formats.

### Preview any DataObject in any admin section {#cms-preview}

The CMS preview panel has historically been available for `Versioned` `DataObject`s in the Pages admin section. This has now been expanded to allow any `DataObject` (regardless of whether it uses the`Versioned` extension) to be previewed in any section of the CMS.
Expand Down