Skip to content

Commit 0c43d7b

Browse files
committed
Update readme
1 parent 1e8865a commit 0c43d7b

4 files changed

Lines changed: 15 additions & 2 deletions

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function run($resource, $args = array())
3333
* ```'max_height'``` - Numeric px value
3434
* ```'cmyktorgb'``` - 1 OR 0
3535
* ```'compression'``` - intelligent (default), ultra OR lossless
36+
* ```'webp'``` - 1 OR 0 (generate or don't generate webp)
3637

3738

3839
The ```$args``` parameter is not required and the defaults are as follows:
@@ -43,7 +44,8 @@ The ```$args``` parameter is not required and the defaults are as follows:
4344
'max_width' => 0,
4445
'max_height' => 0,
4546
'cmyktorgb' => 1,
46-
'compression' => 'intelligent',
47+
'compression' => 'intelligent',
48+
'webp' => 1,
4749
]
4850
```
4951

@@ -117,6 +119,7 @@ We have the following properties and methods available to use for each optimized
117119
- ```$file->getSavedBytes()``` - Returns the total saved bytes.
118120
- ```$file->getSavedPercent()``` - Returns the total saved space in percentage.
119121
- ```$file->getUrl()``` - Returns the optimized image url. You need to download and store it on your server because it will be removed after 1 hour from MegaOptim server
122+
- ```$file->getWebP()``` - Returns NULL if there is no webp version available or ResultWebP instance for the webp version of this file.
120123

121124
To save the optimized images locally we have three methods available:
122125
- ```$file->saveOverwrite()``` - Overwrites the local file with the new optimized file. **Only available when local files are being optimized, not URLs.**

loadnoncomposer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
require_once('src/Http/HTTP.php');
2626
require_once('src/Http/BaseClient.php');
2727
require_once('src/Http/Client.php');
28+
require_once('src/Responses/ResultWebP.php');
2829
require_once('src/Responses/Result.php');
2930
require_once('src/Responses/Response.php');
3031
require_once('src/Responses/Profile.php');

src/Optimizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function run( $resource, $args = array(), $local_wait = false ) {
152152
$tmp_response = $this->service->get_result( $response->getProcessId(), 1 );
153153
if ( $tmp_response->isSuccessful() && ! $tmp_response->isProcessing() ) {
154154
$tmp_response->setLocalResources( $resource );
155-
$tmp_response->setProcessId( $processID );
155+
$tmp_response->setProcessId( $pid );
156156

157157
return $tmp_response;
158158
}

src/Responses/Result.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ class Result implements IFile {
5656
*/
5757
private $url = '';
5858

59+
/**
60+
* WebP Result
61+
* @var ResultWebP
62+
*/
63+
private $webp;
64+
5965
/**
6066
* The local file
6167
* If this is not null it means a file by path was optimized and this is it's local path.
@@ -91,6 +97,9 @@ public function __construct( $result ) {
9197
if ( isset( $result->url ) ) {
9298
$this->url = $result->url;
9399
}
100+
if ( isset( $result->webp ) ) {
101+
$this->webp = new ResultWebP($result);
102+
}
94103
}
95104

96105

0 commit comments

Comments
 (0)