Skip to content

Commit 6f8d570

Browse files
authored
Merge pull request #6 from cjobeili/fix-function-in-method
Fix the usage of curl_file_create
2 parents 7160ef1 + 869d6b1 commit 6f8d570

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

class-imagify.php

+5-7
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,6 @@ public function optimize( $image, $options = array() ) {
8787
return (object) array('success' => false, 'message' => 'Image not readable!');
8888
}
8989

90-
if ( !function_exists('curl_file_create') ) {
91-
function curl_file_create($filename, $mimetype = '', $postname = '') {
92-
return "@$filename;filename=" . ( $postname ?: basename($filename) ) . ( $mimetype ? ";type=$mimetype" : '' );
93-
}
94-
}
95-
9690
$default = array(
9791
'level' => 'aggressive',
9892
'resize' => array(),
@@ -103,7 +97,7 @@ function curl_file_create($filename, $mimetype = '', $postname = '') {
10397
$options = array_merge( $default, $options );
10498

10599
$data = array(
106-
'image' => curl_file_create( $image ),
100+
'image' => $this->createFile( $image ),
107101
'data' => json_encode(
108102
array(
109103
'aggressive' => ( 'aggressive' === $options['level'] ) ? true : false,
@@ -121,6 +115,10 @@ function curl_file_create($filename, $mimetype = '', $postname = '') {
121115
);
122116
}
123117

118+
private function createFile( $image, $mimetype = '', $postname = '' ) {
119+
return "@$filename;filename=" . ( $postname ?: basename($filename) ) . ( $mimetype ? ";type=$mimetype" : '' );
120+
}
121+
124122
/**
125123
* Make an HTTP call using curl.
126124
*

0 commit comments

Comments
 (0)