sourcebroker / webp
Webp converter scenarios
0.10.0
2021-03-11 21:30 UTC
Requires
- php: >=7.0
- rosell-dk/webp-convert: ^2.4
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
What does it do?
This library is short scenarios of working examples for webp on demand which use rosell-dk/webp-convert in background. There will be two scenarios:
- call to image which has no webp version yet will redirect to original source and run webp image converter in background
- call to image which has no webp version yet will stream original source and run webp image converter in background
Next calls to jpg/png will return webp on apache rewrite level.
For now only first scenario is implemented.
Webp images generated after redirect to original source
How to install ?
composer req sourcebroker/webp- Go to folder
vendor/sourcebroker/webp/Resources/WebpRedirectToOriginalAndConvertInBackground - Copy part of htaccess from there to your htaccess or vhost configuration.
- Copy the example
webp.phpto your DocumentRoot folder. Change the path to vendor folder to your needs. - Your webp files will be stored in separate folder in your DocumentRoot folder. By default its
_processed_/webp-images. You can change this folder by replacing_processed_/webp-imagesin.htaccessfile and inwebp.phpfile. - If you open folder
vendor/sourcebroker/webp/Resources/WebpRedirectToOriginalAndConvertInBackground/cms-specificyou will find therehtaccessandwebp.phpfor specific CMSes like for example TYPO3. The path to store files is there selected to best fit the CMS.
How to test?
- Go into Network tab in Chrome DevTools. When you refresh website you should see jpg/png files being redirected to the
same url but with
?processingparameter. - When you refresh the page second time some jpg/png should be already converted. Those will have
webpin columnType - Check you DocumentRoot folder there should be
_processed_/webp-imagesfolder created with webp files.