Compare commits

...

4 Commits

Author SHA1 Message Date
Guy Sartorelli
1261926911
Merge pull request #10282 from creative-commoners/pulls/4/doc-webp-support
WEBP support doc
2022-04-20 10:53:36 +12:00
Maxime Rainville
d7b7b58e5d
Tweaks from peer review
Co-authored-by: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com>
2022-04-20 10:17:09 +12:00
Maxime Rainville
e9d3fe5c00 DOC Explain how to add new Image formats. 2022-04-14 13:56:47 +12:00
Maxime Rainville
e05fed46ea DOC Add changelog entry for WebP support 2022-04-14 11:47:47 +12:00
2 changed files with 68 additions and 0 deletions

View File

@ -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
---
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
```

View File

@ -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)
@ -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.