sourcebroker / webp
Webp converter scenarios
Installs: 11 054
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=7.0
- rosell-dk/webp-convert: ^2.4
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.php
to 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-images
in.htaccess
file and inwebp.php
file. - If you open folder
vendor/sourcebroker/webp/Resources/WebpRedirectToOriginalAndConvertInBackground/cms-specific
you will find therehtaccess
andwebp.php
for 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
?processing
parameter. - When you refresh the page second time some jpg/png should be already converted. Those will have
webp
in columnType
- Check you DocumentRoot folder there should be
_processed_/webp-images
folder created with webp files.