author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:40:08 +0200 | |
changeset 21 | 48c4eec2b7e6 |
parent 19 | 3d72ae0968f4 |
child 22 | 8c2e4d02f4ef |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* WordPress GD Image Editor |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Image_Editor |
|
7 |
*/ |
|
8 |
||
9 |
/** |
|
10 |
* WordPress Image Editor Class for Image Manipulation through GD |
|
11 |
* |
|
12 |
* @since 3.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
13 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
14 |
* @see WP_Image_Editor |
0 | 15 |
*/ |
16 |
class WP_Image_Editor_GD extends WP_Image_Editor { |
|
5 | 17 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
18 |
* GD Resource. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
19 |
* |
18 | 20 |
* @var resource|GdImage |
5 | 21 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
22 |
protected $image; |
0 | 23 |
|
5 | 24 |
public function __destruct() { |
0 | 25 |
if ( $this->image ) { |
16 | 26 |
// We don't need the original in memory anymore. |
0 | 27 |
imagedestroy( $this->image ); |
28 |
} |
|
29 |
} |
|
30 |
||
31 |
/** |
|
32 |
* Checks to see if current environment supports GD. |
|
33 |
* |
|
34 |
* @since 3.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
35 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
36 |
* @param array $args |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
37 |
* @return bool |
0 | 38 |
*/ |
39 |
public static function test( $args = array() ) { |
|
9 | 40 |
if ( ! extension_loaded( 'gd' ) || ! function_exists( 'gd_info' ) ) { |
0 | 41 |
return false; |
9 | 42 |
} |
0 | 43 |
|
16 | 44 |
// On some setups GD library does not provide imagerotate() - Ticket #11536. |
0 | 45 |
if ( isset( $args['methods'] ) && |
16 | 46 |
in_array( 'rotate', $args['methods'], true ) && |
9 | 47 |
! function_exists( 'imagerotate' ) ) { |
0 | 48 |
|
49 |
return false; |
|
50 |
} |
|
51 |
||
52 |
return true; |
|
53 |
} |
|
54 |
||
55 |
/** |
|
56 |
* Checks to see if editor supports the mime-type specified. |
|
57 |
* |
|
58 |
* @since 3.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
59 |
* |
0 | 60 |
* @param string $mime_type |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
61 |
* @return bool |
0 | 62 |
*/ |
63 |
public static function supports_mime_type( $mime_type ) { |
|
64 |
$image_types = imagetypes(); |
|
9 | 65 |
switch ( $mime_type ) { |
0 | 66 |
case 'image/jpeg': |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
67 |
return ( $image_types & IMG_JPG ) !== 0; |
0 | 68 |
case 'image/png': |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
69 |
return ( $image_types & IMG_PNG ) !== 0; |
0 | 70 |
case 'image/gif': |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
71 |
return ( $image_types & IMG_GIF ) !== 0; |
18 | 72 |
case 'image/webp': |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
73 |
return ( $image_types & IMG_WEBP ) !== 0; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
74 |
case 'image/avif': |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
75 |
return ( $image_types & IMG_AVIF ) !== 0 && function_exists( 'imageavif' ); |
0 | 76 |
} |
77 |
||
78 |
return false; |
|
79 |
} |
|
80 |
||
81 |
/** |
|
82 |
* Loads image from $this->file into new GD Resource. |
|
83 |
* |
|
84 |
* @since 3.5.0 |
|
85 |
* |
|
18 | 86 |
* @return true|WP_Error True if loaded successfully; WP_Error on failure. |
0 | 87 |
*/ |
88 |
public function load() { |
|
9 | 89 |
if ( $this->image ) { |
0 | 90 |
return true; |
9 | 91 |
} |
0 | 92 |
|
9 | 93 |
if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) ) { |
19 | 94 |
return new WP_Error( 'error_loading_image', __( 'File does not exist?' ), $this->file ); |
9 | 95 |
} |
0 | 96 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
97 |
// Set artificially high because GD uses uncompressed images in memory. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
98 |
wp_raise_memory_limit( 'image' ); |
5 | 99 |
|
18 | 100 |
$file_contents = @file_get_contents( $this->file ); |
101 |
||
102 |
if ( ! $file_contents ) { |
|
19 | 103 |
return new WP_Error( 'error_loading_image', __( 'File does not exist?' ), $this->file ); |
18 | 104 |
} |
0 | 105 |
|
18 | 106 |
// WebP may not work with imagecreatefromstring(). |
107 |
if ( |
|
108 |
function_exists( 'imagecreatefromwebp' ) && |
|
109 |
( 'image/webp' === wp_get_image_mime( $this->file ) ) |
|
110 |
) { |
|
111 |
$this->image = @imagecreatefromwebp( $this->file ); |
|
112 |
} else { |
|
113 |
$this->image = @imagecreatefromstring( $file_contents ); |
|
114 |
} |
|
115 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
116 |
// AVIF may not work with imagecreatefromstring(). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
117 |
if ( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
118 |
function_exists( 'imagecreatefromavif' ) && |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
119 |
( 'image/avif' === wp_get_image_mime( $this->file ) ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
120 |
) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
121 |
$this->image = @imagecreatefromavif( $this->file ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
122 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
123 |
$this->image = @imagecreatefromstring( $file_contents ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
124 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
125 |
|
18 | 126 |
if ( ! is_gd_image( $this->image ) ) { |
9 | 127 |
return new WP_Error( 'invalid_image', __( 'File is not an image.' ), $this->file ); |
128 |
} |
|
0 | 129 |
|
18 | 130 |
$size = wp_getimagesize( $this->file ); |
131 |
||
9 | 132 |
if ( ! $size ) { |
133 |
return new WP_Error( 'invalid_image', __( 'Could not read image size.' ), $this->file ); |
|
134 |
} |
|
0 | 135 |
|
136 |
if ( function_exists( 'imagealphablending' ) && function_exists( 'imagesavealpha' ) ) { |
|
137 |
imagealphablending( $this->image, false ); |
|
138 |
imagesavealpha( $this->image, true ); |
|
139 |
} |
|
140 |
||
141 |
$this->update_size( $size[0], $size[1] ); |
|
142 |
$this->mime_type = $size['mime']; |
|
143 |
||
5 | 144 |
return $this->set_quality(); |
0 | 145 |
} |
146 |
||
147 |
/** |
|
148 |
* Sets or updates current image size. |
|
149 |
* |
|
150 |
* @since 3.5.0 |
|
151 |
* |
|
152 |
* @param int $width |
|
153 |
* @param int $height |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
154 |
* @return true |
0 | 155 |
*/ |
156 |
protected function update_size( $width = false, $height = false ) { |
|
9 | 157 |
if ( ! $width ) { |
0 | 158 |
$width = imagesx( $this->image ); |
9 | 159 |
} |
0 | 160 |
|
9 | 161 |
if ( ! $height ) { |
0 | 162 |
$height = imagesy( $this->image ); |
9 | 163 |
} |
0 | 164 |
|
165 |
return parent::update_size( $width, $height ); |
|
166 |
} |
|
167 |
||
168 |
/** |
|
169 |
* Resizes current image. |
|
18 | 170 |
* |
171 |
* Wraps `::_resize()` which returns a GD resource or GdImage instance. |
|
0 | 172 |
* |
18 | 173 |
* At minimum, either a height or width must be provided. If one of the two is set |
174 |
* to null, the resize will maintain aspect ratio according to the provided dimension. |
|
5 | 175 |
* |
0 | 176 |
* @since 3.5.0 |
177 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
178 |
* @param int|null $max_w Image width. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
179 |
* @param int|null $max_h Image height. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
180 |
* @param bool|array $crop { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
181 |
* Optional. Image cropping behavior. If false, the image will be scaled (default). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
182 |
* If true, image will be cropped to the specified dimensions using center positions. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
183 |
* If an array, the image will be cropped using the array to specify the crop location: |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
184 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
185 |
* @type string $0 The x crop position. Accepts 'left' 'center', or 'right'. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
186 |
* @type string $1 The y crop position. Accepts 'top', 'center', or 'bottom'. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
187 |
* } |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
188 |
* @return true|WP_Error |
0 | 189 |
*/ |
190 |
public function resize( $max_w, $max_h, $crop = false ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
191 |
if ( ( $this->size['width'] === $max_w ) && ( $this->size['height'] === $max_h ) ) { |
0 | 192 |
return true; |
9 | 193 |
} |
0 | 194 |
|
195 |
$resized = $this->_resize( $max_w, $max_h, $crop ); |
|
196 |
||
18 | 197 |
if ( is_gd_image( $resized ) ) { |
0 | 198 |
imagedestroy( $this->image ); |
199 |
$this->image = $resized; |
|
200 |
return true; |
|
201 |
||
9 | 202 |
} elseif ( is_wp_error( $resized ) ) { |
0 | 203 |
return $resized; |
9 | 204 |
} |
0 | 205 |
|
9 | 206 |
return new WP_Error( 'image_resize_error', __( 'Image resize failed.' ), $this->file ); |
0 | 207 |
} |
208 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
209 |
/** |
16 | 210 |
* @param int $max_w |
211 |
* @param int $max_h |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
212 |
* @param bool|array $crop { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
213 |
* Optional. Image cropping behavior. If false, the image will be scaled (default). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
214 |
* If true, image will be cropped to the specified dimensions using center positions. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
215 |
* If an array, the image will be cropped using the array to specify the crop location: |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
216 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
217 |
* @type string $0 The x crop position. Accepts 'left' 'center', or 'right'. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
218 |
* @type string $1 The y crop position. Accepts 'top', 'center', or 'bottom'. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
219 |
* } |
18 | 220 |
* @return resource|GdImage|WP_Error |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
221 |
*/ |
0 | 222 |
protected function _resize( $max_w, $max_h, $crop = false ) { |
223 |
$dims = image_resize_dimensions( $this->size['width'], $this->size['height'], $max_w, $max_h, $crop ); |
|
16 | 224 |
|
0 | 225 |
if ( ! $dims ) { |
9 | 226 |
return new WP_Error( 'error_getting_dimensions', __( 'Could not calculate resized image dimensions' ), $this->file ); |
0 | 227 |
} |
16 | 228 |
|
0 | 229 |
list( $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ) = $dims; |
230 |
||
231 |
$resized = wp_imagecreatetruecolor( $dst_w, $dst_h ); |
|
232 |
imagecopyresampled( $resized, $this->image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ); |
|
233 |
||
18 | 234 |
if ( is_gd_image( $resized ) ) { |
0 | 235 |
$this->update_size( $dst_w, $dst_h ); |
236 |
return $resized; |
|
237 |
} |
|
238 |
||
9 | 239 |
return new WP_Error( 'image_resize_error', __( 'Image resize failed.' ), $this->file ); |
0 | 240 |
} |
241 |
||
242 |
/** |
|
16 | 243 |
* Create multiple smaller images from a single source. |
244 |
* |
|
245 |
* Attempts to create all sub-sizes and returns the meta data at the end. This |
|
246 |
* may result in the server running out of resources. When it fails there may be few |
|
247 |
* "orphaned" images left over as the meta data is never returned and saved. |
|
248 |
* |
|
249 |
* As of 5.3.0 the preferred way to do this is with `make_subsize()`. It creates |
|
250 |
* the new images one at a time and allows for the meta data to be saved after |
|
251 |
* each new image is created. |
|
0 | 252 |
* |
253 |
* @since 3.5.0 |
|
254 |
* |
|
255 |
* @param array $sizes { |
|
16 | 256 |
* An array of image size data arrays. |
0 | 257 |
* |
5 | 258 |
* Either a height or width must be provided. |
259 |
* If one of the two is set to null, the resize will |
|
16 | 260 |
* maintain aspect ratio according to the source image. |
5 | 261 |
* |
19 | 262 |
* @type array ...$0 { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
263 |
* Array of height, width values, and whether to crop. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
264 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
265 |
* @type int $width Image width. Optional if `$height` is specified. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
266 |
* @type int $height Image height. Optional if `$width` is specified. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
267 |
* @type bool|array $crop Optional. Whether to crop the image. Default false. |
0 | 268 |
* } |
269 |
* } |
|
5 | 270 |
* @return array An array of resized images' metadata by size. |
0 | 271 |
*/ |
272 |
public function multi_resize( $sizes ) { |
|
16 | 273 |
$metadata = array(); |
0 | 274 |
|
275 |
foreach ( $sizes as $size => $size_data ) { |
|
16 | 276 |
$meta = $this->make_subsize( $size_data ); |
0 | 277 |
|
16 | 278 |
if ( ! is_wp_error( $meta ) ) { |
279 |
$metadata[ $size ] = $meta; |
|
0 | 280 |
} |
281 |
} |
|
282 |
||
283 |
return $metadata; |
|
284 |
} |
|
285 |
||
286 |
/** |
|
16 | 287 |
* Create an image sub-size and return the image meta data value for it. |
288 |
* |
|
289 |
* @since 5.3.0 |
|
290 |
* |
|
291 |
* @param array $size_data { |
|
292 |
* Array of size data. |
|
293 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
294 |
* @type int $width The maximum width in pixels. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
295 |
* @type int $height The maximum height in pixels. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
296 |
* @type bool|array $crop Whether to crop the image to exact dimensions. |
16 | 297 |
* } |
298 |
* @return array|WP_Error The image data array for inclusion in the `sizes` array in the image meta, |
|
299 |
* WP_Error object on error. |
|
300 |
*/ |
|
301 |
public function make_subsize( $size_data ) { |
|
302 |
if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) { |
|
303 |
return new WP_Error( 'image_subsize_create_error', __( 'Cannot resize the image. Both width and height are not set.' ) ); |
|
304 |
} |
|
305 |
||
306 |
$orig_size = $this->size; |
|
307 |
||
308 |
if ( ! isset( $size_data['width'] ) ) { |
|
309 |
$size_data['width'] = null; |
|
310 |
} |
|
311 |
||
312 |
if ( ! isset( $size_data['height'] ) ) { |
|
313 |
$size_data['height'] = null; |
|
314 |
} |
|
315 |
||
316 |
if ( ! isset( $size_data['crop'] ) ) { |
|
317 |
$size_data['crop'] = false; |
|
318 |
} |
|
319 |
||
320 |
$resized = $this->_resize( $size_data['width'], $size_data['height'], $size_data['crop'] ); |
|
321 |
||
322 |
if ( is_wp_error( $resized ) ) { |
|
323 |
$saved = $resized; |
|
324 |
} else { |
|
325 |
$saved = $this->_save( $resized ); |
|
326 |
imagedestroy( $resized ); |
|
327 |
} |
|
328 |
||
329 |
$this->size = $orig_size; |
|
330 |
||
331 |
if ( ! is_wp_error( $saved ) ) { |
|
332 |
unset( $saved['path'] ); |
|
333 |
} |
|
334 |
||
335 |
return $saved; |
|
336 |
} |
|
337 |
||
338 |
/** |
|
0 | 339 |
* Crops Image. |
340 |
* |
|
341 |
* @since 3.5.0 |
|
342 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
343 |
* @param int $src_x The start x position to crop from. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
344 |
* @param int $src_y The start y position to crop from. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
345 |
* @param int $src_w The width to crop. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
346 |
* @param int $src_h The height to crop. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
347 |
* @param int $dst_w Optional. The destination width. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
348 |
* @param int $dst_h Optional. The destination height. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
349 |
* @param bool $src_abs Optional. If the source crop points are absolute. |
18 | 350 |
* @return true|WP_Error |
0 | 351 |
*/ |
352 |
public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
353 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
354 |
* If destination width/height isn't specified, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
355 |
* use same as width/height from source. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
356 |
*/ |
9 | 357 |
if ( ! $dst_w ) { |
0 | 358 |
$dst_w = $src_w; |
9 | 359 |
} |
360 |
if ( ! $dst_h ) { |
|
0 | 361 |
$dst_h = $src_h; |
9 | 362 |
} |
0 | 363 |
|
18 | 364 |
foreach ( array( $src_w, $src_h, $dst_w, $dst_h ) as $value ) { |
365 |
if ( ! is_numeric( $value ) || (int) $value <= 0 ) { |
|
366 |
return new WP_Error( 'image_crop_error', __( 'Image crop failed.' ), $this->file ); |
|
367 |
} |
|
368 |
} |
|
369 |
||
370 |
$dst = wp_imagecreatetruecolor( (int) $dst_w, (int) $dst_h ); |
|
0 | 371 |
|
372 |
if ( $src_abs ) { |
|
373 |
$src_w -= $src_x; |
|
374 |
$src_h -= $src_y; |
|
375 |
} |
|
376 |
||
9 | 377 |
if ( function_exists( 'imageantialias' ) ) { |
0 | 378 |
imageantialias( $dst, true ); |
9 | 379 |
} |
0 | 380 |
|
18 | 381 |
imagecopyresampled( $dst, $this->image, 0, 0, (int) $src_x, (int) $src_y, (int) $dst_w, (int) $dst_h, (int) $src_w, (int) $src_h ); |
0 | 382 |
|
18 | 383 |
if ( is_gd_image( $dst ) ) { |
0 | 384 |
imagedestroy( $this->image ); |
385 |
$this->image = $dst; |
|
386 |
$this->update_size(); |
|
387 |
return true; |
|
388 |
} |
|
389 |
||
9 | 390 |
return new WP_Error( 'image_crop_error', __( 'Image crop failed.' ), $this->file ); |
0 | 391 |
} |
392 |
||
393 |
/** |
|
394 |
* Rotates current image counter-clockwise by $angle. |
|
395 |
* Ported from image-edit.php |
|
396 |
* |
|
397 |
* @since 3.5.0 |
|
398 |
* |
|
399 |
* @param float $angle |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
400 |
* @return true|WP_Error |
0 | 401 |
*/ |
402 |
public function rotate( $angle ) { |
|
9 | 403 |
if ( function_exists( 'imagerotate' ) ) { |
5 | 404 |
$transparency = imagecolorallocatealpha( $this->image, 255, 255, 255, 127 ); |
9 | 405 |
$rotated = imagerotate( $this->image, $angle, $transparency ); |
0 | 406 |
|
18 | 407 |
if ( is_gd_image( $rotated ) ) { |
5 | 408 |
imagealphablending( $rotated, true ); |
409 |
imagesavealpha( $rotated, true ); |
|
0 | 410 |
imagedestroy( $this->image ); |
411 |
$this->image = $rotated; |
|
412 |
$this->update_size(); |
|
413 |
return true; |
|
414 |
} |
|
415 |
} |
|
18 | 416 |
|
9 | 417 |
return new WP_Error( 'image_rotate_error', __( 'Image rotate failed.' ), $this->file ); |
0 | 418 |
} |
419 |
||
420 |
/** |
|
421 |
* Flips current image. |
|
422 |
* |
|
423 |
* @since 3.5.0 |
|
424 |
* |
|
9 | 425 |
* @param bool $horz Flip along Horizontal Axis. |
426 |
* @param bool $vert Flip along Vertical Axis. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
427 |
* @return true|WP_Error |
0 | 428 |
*/ |
429 |
public function flip( $horz, $vert ) { |
|
9 | 430 |
$w = $this->size['width']; |
431 |
$h = $this->size['height']; |
|
0 | 432 |
$dst = wp_imagecreatetruecolor( $w, $h ); |
433 |
||
18 | 434 |
if ( is_gd_image( $dst ) ) { |
9 | 435 |
$sx = $vert ? ( $w - 1 ) : 0; |
436 |
$sy = $horz ? ( $h - 1 ) : 0; |
|
0 | 437 |
$sw = $vert ? -$w : $w; |
438 |
$sh = $horz ? -$h : $h; |
|
439 |
||
440 |
if ( imagecopyresampled( $dst, $this->image, 0, 0, $sx, $sy, $w, $h, $sw, $sh ) ) { |
|
441 |
imagedestroy( $this->image ); |
|
442 |
$this->image = $dst; |
|
443 |
return true; |
|
444 |
} |
|
445 |
} |
|
18 | 446 |
|
9 | 447 |
return new WP_Error( 'image_flip_error', __( 'Image flip failed.' ), $this->file ); |
0 | 448 |
} |
449 |
||
450 |
/** |
|
451 |
* Saves current in-memory image to file. |
|
452 |
* |
|
453 |
* @since 3.5.0 |
|
19 | 454 |
* @since 5.9.0 Renamed `$filename` to `$destfilename` to match parent class |
455 |
* for PHP 8 named parameter support. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
456 |
* @since 6.0.0 The `$filesize` value was added to the returned array. |
0 | 457 |
* |
19 | 458 |
* @param string|null $destfilename Optional. Destination filename. Default null. |
459 |
* @param string|null $mime_type Optional. The mime-type. Default null. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
460 |
* @return array|WP_Error { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
461 |
* Array on success or WP_Error if the file failed to save. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
462 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
463 |
* @type string $path Path to the image file. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
464 |
* @type string $file Name of the image file. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
465 |
* @type int $width Image width. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
466 |
* @type int $height Image height. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
467 |
* @type string $mime-type The mime type of the image. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
468 |
* @type int $filesize File size of the image. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
469 |
* } |
0 | 470 |
*/ |
19 | 471 |
public function save( $destfilename = null, $mime_type = null ) { |
472 |
$saved = $this->_save( $this->image, $destfilename, $mime_type ); |
|
0 | 473 |
|
474 |
if ( ! is_wp_error( $saved ) ) { |
|
9 | 475 |
$this->file = $saved['path']; |
0 | 476 |
$this->mime_type = $saved['mime-type']; |
477 |
} |
|
478 |
||
479 |
return $saved; |
|
480 |
} |
|
481 |
||
5 | 482 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
483 |
* @since 3.5.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
484 |
* @since 6.0.0 The `$filesize` value was added to the returned array. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
485 |
* |
18 | 486 |
* @param resource|GdImage $image |
487 |
* @param string|null $filename |
|
488 |
* @param string|null $mime_type |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
489 |
* @return array|WP_Error { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
490 |
* Array on success or WP_Error if the file failed to save. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
491 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
492 |
* @type string $path Path to the image file. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
493 |
* @type string $file Name of the image file. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
494 |
* @type int $width Image width. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
495 |
* @type int $height Image height. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
496 |
* @type string $mime-type The mime type of the image. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
497 |
* @type int $filesize File size of the image. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
498 |
* } |
5 | 499 |
*/ |
0 | 500 |
protected function _save( $image, $filename = null, $mime_type = null ) { |
501 |
list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type ); |
|
502 |
||
9 | 503 |
if ( ! $filename ) { |
0 | 504 |
$filename = $this->generate_filename( null, null, $extension ); |
9 | 505 |
} |
0 | 506 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
507 |
if ( function_exists( 'imageinterlace' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
508 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
509 |
* Filters whether to output progressive images (if available). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
510 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
511 |
* @since 6.5.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
512 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
513 |
* @param bool $interlace Whether to use progressive images for output if available. Default false. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
514 |
* @param string $mime_type The mime type being saved. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
515 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
516 |
imageinterlace( $image, apply_filters( 'image_save_progressive', false, $mime_type ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
517 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
518 |
|
16 | 519 |
if ( 'image/gif' === $mime_type ) { |
9 | 520 |
if ( ! $this->make_image( $filename, 'imagegif', array( $image, $filename ) ) ) { |
521 |
return new WP_Error( 'image_save_error', __( 'Image Editor Save Failed' ) ); |
|
522 |
} |
|
16 | 523 |
} elseif ( 'image/png' === $mime_type ) { |
524 |
// Convert from full colors to index colors, like original PNG. |
|
9 | 525 |
if ( function_exists( 'imageistruecolor' ) && ! imageistruecolor( $image ) ) { |
0 | 526 |
imagetruecolortopalette( $image, false, imagecolorstotal( $image ) ); |
9 | 527 |
} |
0 | 528 |
|
9 | 529 |
if ( ! $this->make_image( $filename, 'imagepng', array( $image, $filename ) ) ) { |
530 |
return new WP_Error( 'image_save_error', __( 'Image Editor Save Failed' ) ); |
|
531 |
} |
|
16 | 532 |
} elseif ( 'image/jpeg' === $mime_type ) { |
9 | 533 |
if ( ! $this->make_image( $filename, 'imagejpeg', array( $image, $filename, $this->get_quality() ) ) ) { |
534 |
return new WP_Error( 'image_save_error', __( 'Image Editor Save Failed' ) ); |
|
535 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
536 |
} elseif ( 'image/webp' === $mime_type ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
537 |
if ( ! function_exists( 'imagewebp' ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
538 |
|| ! $this->make_image( $filename, 'imagewebp', array( $image, $filename, $this->get_quality() ) ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
539 |
) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
540 |
return new WP_Error( 'image_save_error', __( 'Image Editor Save Failed' ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
541 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
542 |
} elseif ( 'image/avif' === $mime_type ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
543 |
if ( ! function_exists( 'imageavif' ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
544 |
|| ! $this->make_image( $filename, 'imageavif', array( $image, $filename, $this->get_quality() ) ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
545 |
) { |
18 | 546 |
return new WP_Error( 'image_save_error', __( 'Image Editor Save Failed' ) ); |
547 |
} |
|
9 | 548 |
} else { |
549 |
return new WP_Error( 'image_save_error', __( 'Image Editor Save Failed' ) ); |
|
0 | 550 |
} |
551 |
||
16 | 552 |
// Set correct file permissions. |
9 | 553 |
$stat = stat( dirname( $filename ) ); |
16 | 554 |
$perms = $stat['mode'] & 0000666; // Same permissions as parent folder, strip off the executable bits. |
555 |
chmod( $filename, $perms ); |
|
0 | 556 |
|
557 |
return array( |
|
5 | 558 |
'path' => $filename, |
16 | 559 |
/** |
560 |
* Filters the name of the saved image file. |
|
561 |
* |
|
562 |
* @since 2.6.0 |
|
563 |
* |
|
564 |
* @param string $filename Name of the file. |
|
565 |
*/ |
|
5 | 566 |
'file' => wp_basename( apply_filters( 'image_make_intermediate_size', $filename ) ), |
567 |
'width' => $this->size['width'], |
|
568 |
'height' => $this->size['height'], |
|
569 |
'mime-type' => $mime_type, |
|
19 | 570 |
'filesize' => wp_filesize( $filename ), |
0 | 571 |
); |
572 |
} |
|
573 |
||
574 |
/** |
|
575 |
* Returns stream of current image. |
|
576 |
* |
|
577 |
* @since 3.5.0 |
|
578 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
579 |
* @param string $mime_type The mime type of the image. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
580 |
* @return bool True on success, false on failure. |
0 | 581 |
*/ |
582 |
public function stream( $mime_type = null ) { |
|
583 |
list( $filename, $extension, $mime_type ) = $this->get_output_format( null, $mime_type ); |
|
584 |
||
585 |
switch ( $mime_type ) { |
|
586 |
case 'image/png': |
|
587 |
header( 'Content-Type: image/png' ); |
|
588 |
return imagepng( $this->image ); |
|
589 |
case 'image/gif': |
|
590 |
header( 'Content-Type: image/gif' ); |
|
591 |
return imagegif( $this->image ); |
|
18 | 592 |
case 'image/webp': |
593 |
if ( function_exists( 'imagewebp' ) ) { |
|
594 |
header( 'Content-Type: image/webp' ); |
|
595 |
return imagewebp( $this->image, null, $this->get_quality() ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
596 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
597 |
// Fall back to JPEG. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
598 |
header( 'Content-Type: image/jpeg' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
599 |
return imagejpeg( $this->image, null, $this->get_quality() ); |
18 | 600 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
601 |
case 'image/avif': |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
602 |
if ( function_exists( 'imageavif' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
603 |
header( 'Content-Type: image/avif' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
604 |
return imageavif( $this->image, null, $this->get_quality() ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
605 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
606 |
// Fall back to JPEG. |
0 | 607 |
default: |
608 |
header( 'Content-Type: image/jpeg' ); |
|
5 | 609 |
return imagejpeg( $this->image, null, $this->get_quality() ); |
0 | 610 |
} |
611 |
} |
|
612 |
||
613 |
/** |
|
614 |
* Either calls editor's save function or handles file as a stream. |
|
615 |
* |
|
616 |
* @since 3.5.0 |
|
617 |
* |
|
19 | 618 |
* @param string $filename |
619 |
* @param callable $callback |
|
620 |
* @param array $arguments |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
621 |
* @return bool |
0 | 622 |
*/ |
19 | 623 |
protected function make_image( $filename, $callback, $arguments ) { |
9 | 624 |
if ( wp_is_stream( $filename ) ) { |
0 | 625 |
$arguments[1] = null; |
9 | 626 |
} |
0 | 627 |
|
19 | 628 |
return parent::make_image( $filename, $callback, $arguments ); |
0 | 629 |
} |
630 |
} |