Ticket #6821: 6821.reabstract.diff
File 6821.reabstract.diff, 10.3 KB (added by , 8 years ago) |
---|
-
wp-includes/class-wp-image-editor-gd.php
diff --git wp-includes/class-wp-image-editor-gd.php wp-includes/class-wp-image-editor-gd.php index 3e7e43f..ca76006 100644
class WP_Image_Editor_GD extends WP_Image_Editor { 25 25 } 26 26 27 27 /** 28 * Checks to see if current environment supports GD 28 * Checks to see if current environment supports GD. 29 29 * 30 30 * @since 3.5.0 31 31 * @access public … … class WP_Image_Editor_GD extends WP_Image_Editor { 40 40 } 41 41 42 42 /** 43 * Loads image from $this->file into new GD Resource 43 * Loads image from $this->file into new GD Resource. 44 44 * 45 * @since 3.5 45 * @since 3.5.0 46 46 * @access protected 47 47 * 48 48 * @return boolean|\WP_Error … … class WP_Image_Editor_GD extends WP_Image_Editor { 72 72 } 73 73 74 74 /** 75 * Sets or updates current image size 75 * Sets or updates current image size. 76 76 * 77 77 * @since 3.5.0 78 78 * @access protected … … class WP_Image_Editor_GD extends WP_Image_Editor { 91 91 } 92 92 93 93 /** 94 * Checks to see if editor supports mime-type specified94 * Checks to see if editor supports the mime-type specified. 95 95 * 96 96 * @since 3.5.0 97 97 * @access public … … class WP_Image_Editor_GD extends WP_Image_Editor { 107 107 108 108 /** 109 109 * Resizes current image. 110 * Wrapper around _resize, since _resize returns a GD Resource 110 * Wraps _resize, since _resize returns a GD Resource. 111 * 112 * @since 3.5.0 113 * @access public 111 114 * 112 115 * @param int $max_w 113 116 * @param int $max_h … … class WP_Image_Editor_GD extends WP_Image_Editor { 153 156 * Processes current image and saves to disk 154 157 * multiple sizes from single source. 155 158 * 159 * @since 3.5.0 160 * @access public 161 * 156 162 * @param array $sizes { {width, height}, ... } 157 163 * @return array 158 164 */ … … class WP_Image_Editor_GD extends WP_Image_Editor { 192 198 * @param int $src_h The height to crop. 193 199 * @param int $dst_w Optional. The destination width. 194 200 * @param int $dst_h Optional. The destination height. 195 * @param int$src_abs Optional. If the source crop points are absolute.201 * @param boolean $src_abs Optional. If the source crop points are absolute. 196 202 * @return boolean|WP_Error 197 203 */ 198 204 public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) { … … class WP_Image_Editor_GD extends WP_Image_Editor { 250 256 } 251 257 252 258 /** 253 * Flips current image 259 * Flips current image. 260 * 261 * @since 3.5.0 262 * @access public 254 263 * 255 264 * @param boolean $horz Horizonal Flip 256 265 * @param boolean $vert Vertical Flip … … class WP_Image_Editor_GD extends WP_Image_Editor { 277 286 } 278 287 279 288 /** 280 * Saves current in-memory image to file 289 * Saves current in-memory image to file. 290 * 291 * @since 3.5.0 292 * @access public 281 293 * 282 294 * @param string $destfilename 283 295 * @param string $mime_type … … class WP_Image_Editor_GD extends WP_Image_Editor { 335 347 } 336 348 337 349 /** 338 * Returns stream of current image 350 * Returns stream of current image. 351 * 352 * @since 3.5.0 353 * @access public 339 354 * 340 355 * @param string $mime_type 341 356 */ -
wp-includes/class-wp-image-editor-imagick.php
diff --git wp-includes/class-wp-image-editor-imagick.php wp-includes/class-wp-image-editor-imagick.php index 1f137fd..601b99b 100644
class WP_Image_Editor_Imagick extends WP_Image_Editor { 44 44 } 45 45 46 46 /** 47 * Loads image from $this->file into new Imagick Object 47 * Loads image from $this->file into new Imagick Object. 48 48 * 49 49 * @since 3.5.0 50 50 * @access protected … … class WP_Image_Editor_Imagick extends WP_Image_Editor { 109 109 } 110 110 111 111 /** 112 * Sets or updates current image size 112 * Sets or updates current image size. 113 113 * 114 114 * @since 3.5.0 115 115 * @access protected … … class WP_Image_Editor_Imagick extends WP_Image_Editor { 138 138 } 139 139 140 140 /** 141 * Checks to see if editor supports mime-type specified141 * Checks to see if editor supports the mime-type specified. 142 142 * 143 143 * @since 3.5.0 144 144 * @access public … … class WP_Image_Editor_Imagick extends WP_Image_Editor { 163 163 /** 164 164 * Resizes current image. 165 165 * 166 * @since 3.5.0 167 * @access public 168 * 166 169 * @param int $max_w 167 170 * @param int $max_h 168 171 * @param boolean $crop … … class WP_Image_Editor_Imagick extends WP_Image_Editor { 199 202 * Processes current image and saves to disk 200 203 * multiple sizes from single source. 201 204 * 205 * @since 3.5.0 206 * @access public 207 * 202 208 * @param array $sizes 203 209 * @return array 204 210 */ … … class WP_Image_Editor_Imagick extends WP_Image_Editor { 246 252 * @param int $src_h The height to crop. 247 253 * @param int $dst_w Optional. The destination width. 248 254 * @param int $dst_h Optional. The destination height. 249 * @param int$src_abs Optional. If the source crop points are absolute.255 * @param boolean $src_abs Optional. If the source crop points are absolute. 250 256 * @return boolean|WP_Error 251 257 */ 252 258 public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) { 253 // Not sure this is compatible.254 259 if ( $src_abs ) { 255 260 $src_w -= $src_x; 256 261 $src_h -= $src_y; … … class WP_Image_Editor_Imagick extends WP_Image_Editor { 302 307 } 303 308 304 309 /** 305 * Flips current image 310 * Flips current image. 306 311 * 307 312 * @since 3.5.0 308 313 * @access public 309 314 * 310 * @param boolean $horz Horizon tal Flip315 * @param boolean $horz Horizonal Flip 311 316 * @param boolean $vert Vertical Flip 312 * @returns boolean 317 * @returns boolean|WP_Error 313 318 */ 314 319 public function flip( $horz, $vert ) { 315 320 try { … … class WP_Image_Editor_Imagick extends WP_Image_Editor { 326 331 } 327 332 328 333 /** 329 * Saves current image to file 334 * Saves current image to file. 335 * 336 * @since 3.5.0 337 * @access public 330 338 * 331 339 * @param string $destfilename 332 340 * @param string $mime_type … … class WP_Image_Editor_Imagick extends WP_Image_Editor { 385 393 } 386 394 387 395 /** 388 * Streams current image to browser 396 * Streams current image to browser. 397 * 398 * @since 3.5.0 399 * @access public 389 400 * 390 401 * @param string $mime_type 391 402 * @return boolean|WP_Error -
wp-includes/class-wp-image-editor.php
diff --git wp-includes/class-wp-image-editor.php wp-includes/class-wp-image-editor.php index 4c227a2..920e4a4 100644
abstract class WP_Image_Editor { 62 62 array( 'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD' ) ); 63 63 64 64 if ( ! $required_methods ) 65 $required_methods = apply_filters( 'wp_image_editor_default_methods', 66 array( 'resize', 'multi_resize', 'crop', 'rotate', 'flip', 'stream' ) ); 65 $required_methods = array(); 67 66 68 67 // Loop over each editor on each request looking for one which will serve this request's needs 69 68 foreach ( $request_order as $editor ) { … … abstract class WP_Image_Editor { 80 79 return false; 81 80 } 82 81 83 abstract protected function load(); // returns bool|WP_Error 82 /** 83 * Loads image from $this->file into editor. 84 * 85 * @since 3.5.0 86 * @access protected 87 * @abstract 88 * 89 * @return boolean|WP_Error True if loaded; WP_Error on failure. 90 */ 91 abstract protected function load(); 92 93 /** 94 * Saves current image to file. 95 * 96 * @since 3.5.0 97 * @access public 98 * @abstract 99 * 100 * @param string $destfilename 101 * @param string $mime_type 102 * @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string} 103 */ 84 104 abstract public function save( $destfilename = null, $mime_type = null ); 85 105 86 106 /** 87 * Implement all of the below to support natively used functions: 88 * 89 * public function resize( $max_w, $max_h, $crop = false ) 90 * public function multi_resize( $sizes ) 91 * public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) 92 * public function rotate( $angle ) 93 * public function flip( $horz, $vert ) 94 * public function stream( $mime_type = null ) 107 * Resizes current image. 108 * 109 * @since 3.5.0 110 * @access public 111 * @abstract 112 * 113 * @param int $max_w 114 * @param int $max_h 115 * @param boolean $crop 116 * @return boolean|WP_Error 117 */ 118 abstract public function resize( $max_w, $max_h, $crop = false ); 119 120 /** 121 * Processes current image and saves to disk 122 * multiple sizes from single source. 123 * 124 * @since 3.5.0 125 * @access public 126 * @abstract 127 * 128 * @param array $sizes 129 * @return array 130 */ 131 abstract public function multi_resize( $sizes ); 132 133 /** 134 * Crops Image. 135 * 136 * @since 3.5.0 137 * @access public 138 * @abstract 139 * 140 * @param string|int $src The source file or Attachment ID. 141 * @param int $src_x The start x position to crop from. 142 * @param int $src_y The start y position to crop from. 143 * @param int $src_w The width to crop. 144 * @param int $src_h The height to crop. 145 * @param int $dst_w Optional. The destination width. 146 * @param int $dst_h Optional. The destination height. 147 * @param boolean $src_abs Optional. If the source crop points are absolute. 148 * @return boolean|WP_Error 149 */ 150 abstract public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ); 151 152 /** 153 * Rotates current image counter-clockwise by $angle. 154 * 155 * @since 3.5.0 156 * @access public 157 * @abstract 158 * 159 * @param float $angle 160 * @return boolean|WP_Error 161 */ 162 abstract public function rotate( $angle ); 163 164 /** 165 * Flips current image. 166 * 167 * @since 3.5.0 168 * @access public 169 * @abstract 170 * 171 * @param boolean $horz Horizonal Flip 172 * @param boolean $vert Vertical Flip 173 * @return boolean|WP_Error 174 */ 175 abstract public function flip( $horz, $vert ); 176 177 /** 178 * Streams current image to browser. 179 * 180 * @since 3.5.0 181 * @access public 182 * @abstract 183 * 184 * @param string $mime_type 185 * @return boolean|WP_Error 95 186 */ 187 abstract public function stream( $mime_type = null ); 96 188 97 189 /** 98 190 * Checks to see if current environment supports the editor chosen. … … abstract class WP_Image_Editor { 110 202 } 111 203 112 204 /** 113 * Checks to see if editor supports mime-type specified205 * Checks to see if editor supports the mime-type specified. 114 206 * Must be overridden in a sub-class. 115 207 * 116 208 * @since 3.5.0 … … abstract class WP_Image_Editor { 125 217 } 126 218 127 219 /** 128 * Gets dimensions of image 220 * Gets dimensions of image. 129 221 * 130 222 * @since 3.5.0 131 223 * @access public … … abstract class WP_Image_Editor { 137 229 } 138 230 139 231 /** 140 * Sets current image size 232 * Sets current image size. 141 233 * 142 234 * @since 3.5.0 143 235 * @access protected