| 1 | diff --git wp-includes/class-wp-image-editor-gd.php wp-includes/class-wp-image-editor-gd.php |
|---|
| 2 | index 3e7e43f..ca76006 100644 |
|---|
| 3 | --- wp-includes/class-wp-image-editor-gd.php |
|---|
| 4 | +++ wp-includes/class-wp-image-editor-gd.php |
|---|
| 5 | @@ -25,7 +25,7 @@ class WP_Image_Editor_GD extends WP_Image_Editor { |
|---|
| 6 | } |
|---|
| 7 | |
|---|
| 8 | /** |
|---|
| 9 | - * Checks to see if current environment supports GD |
|---|
| 10 | + * Checks to see if current environment supports GD. |
|---|
| 11 | * |
|---|
| 12 | * @since 3.5.0 |
|---|
| 13 | * @access public |
|---|
| 14 | @@ -40,9 +40,9 @@ class WP_Image_Editor_GD extends WP_Image_Editor { |
|---|
| 15 | } |
|---|
| 16 | |
|---|
| 17 | /** |
|---|
| 18 | - * Loads image from $this->file into new GD Resource |
|---|
| 19 | + * Loads image from $this->file into new GD Resource. |
|---|
| 20 | * |
|---|
| 21 | - * @since 3.5 |
|---|
| 22 | + * @since 3.5.0 |
|---|
| 23 | * @access protected |
|---|
| 24 | * |
|---|
| 25 | * @return boolean|\WP_Error |
|---|
| 26 | @@ -72,7 +72,7 @@ class WP_Image_Editor_GD extends WP_Image_Editor { |
|---|
| 27 | } |
|---|
| 28 | |
|---|
| 29 | /** |
|---|
| 30 | - * Sets or updates current image size |
|---|
| 31 | + * Sets or updates current image size. |
|---|
| 32 | * |
|---|
| 33 | * @since 3.5.0 |
|---|
| 34 | * @access protected |
|---|
| 35 | @@ -91,7 +91,7 @@ class WP_Image_Editor_GD extends WP_Image_Editor { |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | /** |
|---|
| 39 | - * Checks to see if editor supports mime-type specified |
|---|
| 40 | + * Checks to see if editor supports the mime-type specified. |
|---|
| 41 | * |
|---|
| 42 | * @since 3.5.0 |
|---|
| 43 | * @access public |
|---|
| 44 | @@ -107,7 +107,10 @@ class WP_Image_Editor_GD extends WP_Image_Editor { |
|---|
| 45 | |
|---|
| 46 | /** |
|---|
| 47 | * Resizes current image. |
|---|
| 48 | - * Wrapper around _resize, since _resize returns a GD Resource |
|---|
| 49 | + * Wraps _resize, since _resize returns a GD Resource. |
|---|
| 50 | + * |
|---|
| 51 | + * @since 3.5.0 |
|---|
| 52 | + * @access public |
|---|
| 53 | * |
|---|
| 54 | * @param int $max_w |
|---|
| 55 | * @param int $max_h |
|---|
| 56 | @@ -153,6 +156,9 @@ class WP_Image_Editor_GD extends WP_Image_Editor { |
|---|
| 57 | * Processes current image and saves to disk |
|---|
| 58 | * multiple sizes from single source. |
|---|
| 59 | * |
|---|
| 60 | + * @since 3.5.0 |
|---|
| 61 | + * @access public |
|---|
| 62 | + * |
|---|
| 63 | * @param array $sizes { {width, height}, ... } |
|---|
| 64 | * @return array |
|---|
| 65 | */ |
|---|
| 66 | @@ -192,7 +198,7 @@ class WP_Image_Editor_GD extends WP_Image_Editor { |
|---|
| 67 | * @param int $src_h The height to crop. |
|---|
| 68 | * @param int $dst_w Optional. The destination width. |
|---|
| 69 | * @param int $dst_h Optional. The destination height. |
|---|
| 70 | - * @param int $src_abs Optional. If the source crop points are absolute. |
|---|
| 71 | + * @param boolean $src_abs Optional. If the source crop points are absolute. |
|---|
| 72 | * @return boolean|WP_Error |
|---|
| 73 | */ |
|---|
| 74 | public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) { |
|---|
| 75 | @@ -250,7 +256,10 @@ class WP_Image_Editor_GD extends WP_Image_Editor { |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | /** |
|---|
| 79 | - * Flips current image |
|---|
| 80 | + * Flips current image. |
|---|
| 81 | + * |
|---|
| 82 | + * @since 3.5.0 |
|---|
| 83 | + * @access public |
|---|
| 84 | * |
|---|
| 85 | * @param boolean $horz Horizonal Flip |
|---|
| 86 | * @param boolean $vert Vertical Flip |
|---|
| 87 | @@ -277,7 +286,10 @@ class WP_Image_Editor_GD extends WP_Image_Editor { |
|---|
| 88 | } |
|---|
| 89 | |
|---|
| 90 | /** |
|---|
| 91 | - * Saves current in-memory image to file |
|---|
| 92 | + * Saves current in-memory image to file. |
|---|
| 93 | + * |
|---|
| 94 | + * @since 3.5.0 |
|---|
| 95 | + * @access public |
|---|
| 96 | * |
|---|
| 97 | * @param string $destfilename |
|---|
| 98 | * @param string $mime_type |
|---|
| 99 | @@ -335,7 +347,10 @@ class WP_Image_Editor_GD extends WP_Image_Editor { |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | /** |
|---|
| 103 | - * Returns stream of current image |
|---|
| 104 | + * Returns stream of current image. |
|---|
| 105 | + * |
|---|
| 106 | + * @since 3.5.0 |
|---|
| 107 | + * @access public |
|---|
| 108 | * |
|---|
| 109 | * @param string $mime_type |
|---|
| 110 | */ |
|---|
| 111 | diff --git wp-includes/class-wp-image-editor-imagick.php wp-includes/class-wp-image-editor-imagick.php |
|---|
| 112 | index 1f137fd..601b99b 100644 |
|---|
| 113 | --- wp-includes/class-wp-image-editor-imagick.php |
|---|
| 114 | +++ wp-includes/class-wp-image-editor-imagick.php |
|---|
| 115 | @@ -44,7 +44,7 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | /** |
|---|
| 119 | - * Loads image from $this->file into new Imagick Object |
|---|
| 120 | + * Loads image from $this->file into new Imagick Object. |
|---|
| 121 | * |
|---|
| 122 | * @since 3.5.0 |
|---|
| 123 | * @access protected |
|---|
| 124 | @@ -109,7 +109,7 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | /** |
|---|
| 128 | - * Sets or updates current image size |
|---|
| 129 | + * Sets or updates current image size. |
|---|
| 130 | * |
|---|
| 131 | * @since 3.5.0 |
|---|
| 132 | * @access protected |
|---|
| 133 | @@ -138,7 +138,7 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { |
|---|
| 134 | } |
|---|
| 135 | |
|---|
| 136 | /** |
|---|
| 137 | - * Checks to see if editor supports mime-type specified |
|---|
| 138 | + * Checks to see if editor supports the mime-type specified. |
|---|
| 139 | * |
|---|
| 140 | * @since 3.5.0 |
|---|
| 141 | * @access public |
|---|
| 142 | @@ -163,6 +163,9 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { |
|---|
| 143 | /** |
|---|
| 144 | * Resizes current image. |
|---|
| 145 | * |
|---|
| 146 | + * @since 3.5.0 |
|---|
| 147 | + * @access public |
|---|
| 148 | + * |
|---|
| 149 | * @param int $max_w |
|---|
| 150 | * @param int $max_h |
|---|
| 151 | * @param boolean $crop |
|---|
| 152 | @@ -199,6 +202,9 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { |
|---|
| 153 | * Processes current image and saves to disk |
|---|
| 154 | * multiple sizes from single source. |
|---|
| 155 | * |
|---|
| 156 | + * @since 3.5.0 |
|---|
| 157 | + * @access public |
|---|
| 158 | + * |
|---|
| 159 | * @param array $sizes |
|---|
| 160 | * @return array |
|---|
| 161 | */ |
|---|
| 162 | @@ -246,11 +252,10 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { |
|---|
| 163 | * @param int $src_h The height to crop. |
|---|
| 164 | * @param int $dst_w Optional. The destination width. |
|---|
| 165 | * @param int $dst_h Optional. The destination height. |
|---|
| 166 | - * @param int $src_abs Optional. If the source crop points are absolute. |
|---|
| 167 | + * @param boolean $src_abs Optional. If the source crop points are absolute. |
|---|
| 168 | * @return boolean|WP_Error |
|---|
| 169 | */ |
|---|
| 170 | public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) { |
|---|
| 171 | - // Not sure this is compatible. |
|---|
| 172 | if ( $src_abs ) { |
|---|
| 173 | $src_w -= $src_x; |
|---|
| 174 | $src_h -= $src_y; |
|---|
| 175 | @@ -302,14 +307,14 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | /** |
|---|
| 179 | - * Flips current image |
|---|
| 180 | + * Flips current image. |
|---|
| 181 | * |
|---|
| 182 | * @since 3.5.0 |
|---|
| 183 | * @access public |
|---|
| 184 | * |
|---|
| 185 | - * @param boolean $horz Horizontal Flip |
|---|
| 186 | + * @param boolean $horz Horizonal Flip |
|---|
| 187 | * @param boolean $vert Vertical Flip |
|---|
| 188 | - * @returns boolean |
|---|
| 189 | + * @returns boolean|WP_Error |
|---|
| 190 | */ |
|---|
| 191 | public function flip( $horz, $vert ) { |
|---|
| 192 | try { |
|---|
| 193 | @@ -326,7 +331,10 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { |
|---|
| 194 | } |
|---|
| 195 | |
|---|
| 196 | /** |
|---|
| 197 | - * Saves current image to file |
|---|
| 198 | + * Saves current image to file. |
|---|
| 199 | + * |
|---|
| 200 | + * @since 3.5.0 |
|---|
| 201 | + * @access public |
|---|
| 202 | * |
|---|
| 203 | * @param string $destfilename |
|---|
| 204 | * @param string $mime_type |
|---|
| 205 | @@ -385,7 +393,10 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { |
|---|
| 206 | } |
|---|
| 207 | |
|---|
| 208 | /** |
|---|
| 209 | - * Streams current image to browser |
|---|
| 210 | + * Streams current image to browser. |
|---|
| 211 | + * |
|---|
| 212 | + * @since 3.5.0 |
|---|
| 213 | + * @access public |
|---|
| 214 | * |
|---|
| 215 | * @param string $mime_type |
|---|
| 216 | * @return boolean|WP_Error |
|---|
| 217 | diff --git wp-includes/class-wp-image-editor.php wp-includes/class-wp-image-editor.php |
|---|
| 218 | index 4c227a2..920e4a4 100644 |
|---|
| 219 | --- wp-includes/class-wp-image-editor.php |
|---|
| 220 | +++ wp-includes/class-wp-image-editor.php |
|---|
| 221 | @@ -62,8 +62,7 @@ abstract class WP_Image_Editor { |
|---|
| 222 | array( 'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD' ) ); |
|---|
| 223 | |
|---|
| 224 | if ( ! $required_methods ) |
|---|
| 225 | - $required_methods = apply_filters( 'wp_image_editor_default_methods', |
|---|
| 226 | - array( 'resize', 'multi_resize', 'crop', 'rotate', 'flip', 'stream' ) ); |
|---|
| 227 | + $required_methods = array(); |
|---|
| 228 | |
|---|
| 229 | // Loop over each editor on each request looking for one which will serve this request's needs |
|---|
| 230 | foreach ( $request_order as $editor ) { |
|---|
| 231 | @@ -80,19 +79,112 @@ abstract class WP_Image_Editor { |
|---|
| 232 | return false; |
|---|
| 233 | } |
|---|
| 234 | |
|---|
| 235 | - abstract protected function load(); // returns bool|WP_Error |
|---|
| 236 | + /** |
|---|
| 237 | + * Loads image from $this->file into editor. |
|---|
| 238 | + * |
|---|
| 239 | + * @since 3.5.0 |
|---|
| 240 | + * @access protected |
|---|
| 241 | + * @abstract |
|---|
| 242 | + * |
|---|
| 243 | + * @return boolean|WP_Error True if loaded; WP_Error on failure. |
|---|
| 244 | + */ |
|---|
| 245 | + abstract protected function load(); |
|---|
| 246 | + |
|---|
| 247 | + /** |
|---|
| 248 | + * Saves current image to file. |
|---|
| 249 | + * |
|---|
| 250 | + * @since 3.5.0 |
|---|
| 251 | + * @access public |
|---|
| 252 | + * @abstract |
|---|
| 253 | + * |
|---|
| 254 | + * @param string $destfilename |
|---|
| 255 | + * @param string $mime_type |
|---|
| 256 | + * @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string} |
|---|
| 257 | + */ |
|---|
| 258 | abstract public function save( $destfilename = null, $mime_type = null ); |
|---|
| 259 | |
|---|
| 260 | /** |
|---|
| 261 | - * Implement all of the below to support natively used functions: |
|---|
| 262 | - * |
|---|
| 263 | - * public function resize( $max_w, $max_h, $crop = false ) |
|---|
| 264 | - * public function multi_resize( $sizes ) |
|---|
| 265 | - * public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) |
|---|
| 266 | - * public function rotate( $angle ) |
|---|
| 267 | - * public function flip( $horz, $vert ) |
|---|
| 268 | - * public function stream( $mime_type = null ) |
|---|
| 269 | + * Resizes current image. |
|---|
| 270 | + * |
|---|
| 271 | + * @since 3.5.0 |
|---|
| 272 | + * @access public |
|---|
| 273 | + * @abstract |
|---|
| 274 | + * |
|---|
| 275 | + * @param int $max_w |
|---|
| 276 | + * @param int $max_h |
|---|
| 277 | + * @param boolean $crop |
|---|
| 278 | + * @return boolean|WP_Error |
|---|
| 279 | + */ |
|---|
| 280 | + abstract public function resize( $max_w, $max_h, $crop = false ); |
|---|
| 281 | + |
|---|
| 282 | + /** |
|---|
| 283 | + * Processes current image and saves to disk |
|---|
| 284 | + * multiple sizes from single source. |
|---|
| 285 | + * |
|---|
| 286 | + * @since 3.5.0 |
|---|
| 287 | + * @access public |
|---|
| 288 | + * @abstract |
|---|
| 289 | + * |
|---|
| 290 | + * @param array $sizes |
|---|
| 291 | + * @return array |
|---|
| 292 | + */ |
|---|
| 293 | + abstract public function multi_resize( $sizes ); |
|---|
| 294 | + |
|---|
| 295 | + /** |
|---|
| 296 | + * Crops Image. |
|---|
| 297 | + * |
|---|
| 298 | + * @since 3.5.0 |
|---|
| 299 | + * @access public |
|---|
| 300 | + * @abstract |
|---|
| 301 | + * |
|---|
| 302 | + * @param string|int $src The source file or Attachment ID. |
|---|
| 303 | + * @param int $src_x The start x position to crop from. |
|---|
| 304 | + * @param int $src_y The start y position to crop from. |
|---|
| 305 | + * @param int $src_w The width to crop. |
|---|
| 306 | + * @param int $src_h The height to crop. |
|---|
| 307 | + * @param int $dst_w Optional. The destination width. |
|---|
| 308 | + * @param int $dst_h Optional. The destination height. |
|---|
| 309 | + * @param boolean $src_abs Optional. If the source crop points are absolute. |
|---|
| 310 | + * @return boolean|WP_Error |
|---|
| 311 | + */ |
|---|
| 312 | + abstract public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ); |
|---|
| 313 | + |
|---|
| 314 | + /** |
|---|
| 315 | + * Rotates current image counter-clockwise by $angle. |
|---|
| 316 | + * |
|---|
| 317 | + * @since 3.5.0 |
|---|
| 318 | + * @access public |
|---|
| 319 | + * @abstract |
|---|
| 320 | + * |
|---|
| 321 | + * @param float $angle |
|---|
| 322 | + * @return boolean|WP_Error |
|---|
| 323 | + */ |
|---|
| 324 | + abstract public function rotate( $angle ); |
|---|
| 325 | + |
|---|
| 326 | + /** |
|---|
| 327 | + * Flips current image. |
|---|
| 328 | + * |
|---|
| 329 | + * @since 3.5.0 |
|---|
| 330 | + * @access public |
|---|
| 331 | + * @abstract |
|---|
| 332 | + * |
|---|
| 333 | + * @param boolean $horz Horizonal Flip |
|---|
| 334 | + * @param boolean $vert Vertical Flip |
|---|
| 335 | + * @return boolean|WP_Error |
|---|
| 336 | + */ |
|---|
| 337 | + abstract public function flip( $horz, $vert ); |
|---|
| 338 | + |
|---|
| 339 | + /** |
|---|
| 340 | + * Streams current image to browser. |
|---|
| 341 | + * |
|---|
| 342 | + * @since 3.5.0 |
|---|
| 343 | + * @access public |
|---|
| 344 | + * @abstract |
|---|
| 345 | + * |
|---|
| 346 | + * @param string $mime_type |
|---|
| 347 | + * @return boolean|WP_Error |
|---|
| 348 | */ |
|---|
| 349 | + abstract public function stream( $mime_type = null ); |
|---|
| 350 | |
|---|
| 351 | /** |
|---|
| 352 | * Checks to see if current environment supports the editor chosen. |
|---|
| 353 | @@ -110,7 +202,7 @@ abstract class WP_Image_Editor { |
|---|
| 354 | } |
|---|
| 355 | |
|---|
| 356 | /** |
|---|
| 357 | - * Checks to see if editor supports mime-type specified |
|---|
| 358 | + * Checks to see if editor supports the mime-type specified. |
|---|
| 359 | * Must be overridden in a sub-class. |
|---|
| 360 | * |
|---|
| 361 | * @since 3.5.0 |
|---|
| 362 | @@ -125,7 +217,7 @@ abstract class WP_Image_Editor { |
|---|
| 363 | } |
|---|
| 364 | |
|---|
| 365 | /** |
|---|
| 366 | - * Gets dimensions of image |
|---|
| 367 | + * Gets dimensions of image. |
|---|
| 368 | * |
|---|
| 369 | * @since 3.5.0 |
|---|
| 370 | * @access public |
|---|
| 371 | @@ -137,7 +229,7 @@ abstract class WP_Image_Editor { |
|---|
| 372 | } |
|---|
| 373 | |
|---|
| 374 | /** |
|---|
| 375 | - * Sets current image size |
|---|
| 376 | + * Sets current image size. |
|---|
| 377 | * |
|---|
| 378 | * @since 3.5.0 |
|---|
| 379 | * @access protected |
|---|