Changeset 57524
- Timestamp:
- 02/02/2024 05:46:50 PM (6 months ago)
- Location:
- trunk
- Files:
-
- 7 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpcs.xml.dist
r57264 r57524 60 60 <exclude-pattern>/src/wp-includes/class-simplepie\.php</exclude-pattern> 61 61 <exclude-pattern>/src/wp-includes/class-snoopy\.php</exclude-pattern> 62 62 63 <exclude-pattern>/src/wp-includes/deprecated\.php</exclude-pattern> 63 64 <exclude-pattern>/src/wp-includes/ms-deprecated\.php</exclude-pattern> -
trunk/src/js/_enqueues/vendor/plupload/handlers.js
r57231 r57524 609 609 up.removeFile( file ); 610 610 return; 611 612 613 614 615 611 616 } 612 617 -
trunk/src/js/_enqueues/vendor/plupload/wp-plupload.js
r54085 r57524 364 364 up.removeFile( file ); 365 365 return; 366 367 368 369 370 366 371 } 367 372 -
trunk/src/js/_enqueues/vendor/thickbox/thickbox.js
r53451 r57524 77 77 } 78 78 79 var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$|\.webp$ /;79 var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$|\.webp$/; 80 80 var urlType = baseURL.toLowerCase().match(urlString); 81 81 … … 85 85 urlType == '.gif' || 86 86 urlType == '.bmp' || 87 urlType == '.webp' 87 urlType == '.webp' || 88 urlType == '.avif' 88 89 ){//code to show images 89 90 -
trunk/src/js/media/controllers/library.js
r52073 r57524 197 197 // If uploading, we know the filename but not the mime type. 198 198 if ( attachment.get('uploading') ) { 199 return /\.(jpe?g|png|gif|webp )$/i.test( attachment.get('filename') );199 return /\.(jpe?g|png|gif|webp)$/i.test( attachment.get('filename') ); 200 200 } 201 201 -
trunk/src/wp-admin/includes/image-edit.php
r56653 r57524 391 391 } 392 392 return false; 393 394 395 396 397 398 393 399 default: 394 400 return false; … … 493 499 if ( function_exists( 'imagewebp' ) ) { 494 500 return imagewebp( $image, $filename ); 501 502 503 504 505 495 506 } 496 507 return false; -
trunk/src/wp-admin/includes/image.php
r57267 r57524 1007 1007 */ 1008 1008 function file_is_displayable_image( $path ) { 1009 $displayable_image_types = array( IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_ICO, IMAGETYPE_WEBP );1009 $displayable_image_types = array( IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_ICO, IMAGETYPE_WEBP ); 1010 1010 1011 1011 $info = wp_getimagesize( $path ); -
trunk/src/wp-admin/includes/media.php
r57181 r57524 2199 2199 } 2200 2200 2201 2202 2203 2204 2205 2201 2206 /** 2202 2207 * Filters the default Plupload settings. -
trunk/src/wp-admin/includes/schema.php
r57389 r57524 1251 1251 'gif', 1252 1252 'webp', 1253 1253 1254 // Video. 1254 1255 'mov', -
trunk/src/wp-includes/class-wp-image-editor-gd.php
r56418 r57524 72 72 case 'image/webp': 73 73 return ( $image_types & IMG_WEBP ) != 0; 74 75 74 76 } 75 77 … … 112 114 } 113 115 116 117 118 119 120 121 122 123 124 125 114 126 if ( ! is_gd_image( $this->image ) ) { 115 127 return new WP_Error( 'invalid_image', __( 'File is not an image.' ), $this->file ); … … 512 524 } elseif ( 'image/webp' == $mime_type ) { 513 525 if ( ! function_exists( 'imagewebp' ) || ! $this->make_image( $filename, 'imagewebp', array( $image, $filename, $this->get_quality() ) ) ) { 526 527 528 529 514 530 return new WP_Error( 'image_save_error', __( 'Image Editor Save Failed' ) ); 515 531 } … … 562 578 header( 'Content-Type: image/webp' ); 563 579 return imagewebp( $this->image, null, $this->get_quality() ); 580 581 582 583 564 584 } 565 // Fall back to the default if webp isn't supported. 585 case 'image/avif': 586 if ( function_exists( 'imageavif' ) ) { 587 header( 'Content-Type: image/avif' ); 588 return imageavif( $this->image, null, $this->get_quality() ); 589 } 590 // Fall back to JPEG. 566 591 default: 567 592 header( 'Content-Type: image/jpeg' ); -
trunk/src/wp-includes/class-wp-image-editor-imagick.php
r56547 r57524 220 220 } 221 221 break; 222 222 223 default: 223 224 $this->image->setImageCompressionQuality( $quality ); … … 255 256 if ( ! $height ) { 256 257 $height = $size['height']; 258 259 260 261 262 263 264 265 266 267 257 268 } 258 269 -
trunk/src/wp-includes/class-wp-image-editor.php
r56536 r57524 319 319 break; 320 320 case 'image/jpeg': 321 321 322 default: 322 323 $quality = $this->default_quality; -
trunk/src/wp-includes/class-wp-theme.php
r56978 r57524 1264 1264 } 1265 1265 1266 foreach ( array( 'png', 'gif', 'jpg', 'jpeg', 'webp' ) as $ext ) {1266 foreach ( array( 'png', 'gif', 'jpg', 'jpeg', 'webp' ) as $ext ) { 1267 1267 if ( file_exists( $this->get_stylesheet_directory() . "/screenshot.$ext" ) ) { 1268 1268 $this->cache_add( 'screenshot', 'screenshot.' . $ext ); -
trunk/src/wp-includes/compat.php
r57337 r57524 530 530 define( 'IMG_WEBP', IMAGETYPE_WEBP ); 531 531 } 532 533 534 535 536 537 538 539 540 541 -
trunk/src/wp-includes/customize/class-wp-customize-media-control.php
r56193 r57524 94 94 */ 95 95 $ext = substr( $this->setting->default, -3 ); 96 $type = in_array( $ext, array( 'jpg', 'png', 'gif', 'bmp', 'webp' ), true ) ? 'image' : 'document';96 $type = in_array( $ext, array( 'jpg', 'png', 'gif', 'bmp', 'webp' ), true ) ? 'image' : 'document'; 97 97 98 98 $default_attachment = array( -
trunk/src/wp-includes/deprecated.php
r57511 r57524 3337 3337 case 'image/webp': 3338 3338 return (imagetypes() & IMG_WEBP) != 0; 3339 } 3339 case 'image/avif': 3340 return (imagetypes() & IMG_AVIF) != 0; 3341 } 3340 3342 } else { 3341 3343 switch( $mime_type ) { … … 3348 3350 case 'image/webp': 3349 3351 return function_exists('imagecreatefromwebp'); 3352 3353 3350 3354 } 3351 3355 } -
trunk/src/wp-includes/formatting.php
r57302 r57524 3465 3465 $matches = array(); 3466 3466 $ext = preg_match( '/\.([^.]+)$/', $img, $matches ) ? strtolower( $matches[1] ) : false; 3467 $image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'webp' );3467 $image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'webp' ); 3468 3468 3469 3469 // Don't convert smilies that aren't images - they're probably emoji. -
trunk/src/wp-includes/functions.php
r57509 r57524 3118 3118 'image/tiff' => 'tif', 3119 3119 'image/webp' => 'webp', 3120 3120 3121 ) 3121 3122 ); … … 3296 3297 * @since 4.7.1 3297 3298 * @since 5.8.0 Added support for WebP images. 3299 3298 3300 * 3299 3301 * @param string $file Full path to the file. … … 3350 3352 $mime = 'image/webp'; 3351 3353 } 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3352 3373 } catch ( Exception $e ) { 3353 3374 $mime = false; … … 3389 3410 'tiff|tif' => 'image/tiff', 3390 3411 'webp' => 'image/webp', 3412 3391 3413 'ico' => 'image/x-icon', 3392 3414 'heic' => 'image/heic', … … 3510 3532 'ext2type', 3511 3533 array( 3512 'image' => array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico', 'heic', 'webp' ),3534 'image' => array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico', 'heic', 'webp' ), 3513 3535 'audio' => array( 'aac', 'ac3', 'aif', 'aiff', 'flac', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' ), 3514 3536 'video' => array( '3g2', '3gp', '3gpp', 'asf', 'avi', 'divx', 'dv', 'flv', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt', 'rm', 'vob', 'wmv' ), -
trunk/src/wp-includes/media.php
r57294 r57524 4101 4101 require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php'; 4102 4102 require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php'; 4103 4103 4104 /** 4104 4105 * Filters the list of image editing library classes. … … 4203 4204 if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) { 4204 4205 $defaults['webp_upload_error'] = true; 4206 4207 4208 4209 4210 4205 4211 } 4206 4212 … … 5481 5487 * @since 5.7.0 5482 5488 * @since 5.8.0 Added support for WebP images. 5489 5483 5490 * 5484 5491 * @param string $filename The file path. … … 5513 5520 } 5514 5521 5515 if ( false !== $info ) { 5522 if ( 5523 ! empty( $info ) && 5524 // Some PHP versions return 0x0 sizes from `getimagesize` for unrecognized image formats, including AVIFs. 5525 ! ( empty( $info[0] ) && empty( $info[1] ) ) 5526 ) { 5516 5527 return $info; 5517 5528 } … … 5542 5553 } 5543 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5544 5578 // The image could not be parsed. 5545 5579 return false; 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5546 5622 } 5547 5623 -
trunk/src/wp-includes/post.php
r57273 r57524 6701 6701 switch ( $type ) { 6702 6702 case 'image': 6703 $image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'webp' );6703 $image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'webp' ); 6704 6704 return in_array( $ext, $image_exts, true ); 6705 6705 -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
r57380 r57524 457 457 } 458 458 459 $supported_types = array( 'image/jpeg', 'image/png', 'image/gif', 'image/webp' );459 $supported_types = array( 'image/jpeg', 'image/png', 'image/gif', 'image/webp' ); 460 460 $mime_type = get_post_mime_type( $attachment_id ); 461 461 if ( ! in_array( $mime_type, $supported_types, true ) ) { -
trunk/tests/phpunit/tests/functions.php
r57284 r57524 1371 1371 false, 1372 1372 ), 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1373 1393 ); 1374 1394 … … 1496 1516 DIR_TESTDATA . '/uploads/dashicons.woff', 1497 1517 false, 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1498 1562 ), 1499 1563 ); -
trunk/tests/phpunit/tests/image/editor.php
r56547 r57524 293 293 */ 294 294 public function test_wp_get_webp_info( $file, $expected ) { 295 $editor = wp_get_image_editor( $file );296 297 if ( is_wp_error( $editor ) || ! $editor->supports_mime_type( 'image/webp' ) ) {298 $this->markTestSkipped( sprintf( 'No WebP support in the editor engine %s on this system.', $this->editor_engine ) );299 }300 301 295 $file_data = wp_get_webp_info( $file ); 302 296 $this->assertSame( $expected, $file_data ); … … 364 358 ); 365 359 } 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 366 461 } -
trunk/tests/phpunit/tests/image/functions.php
r56559 r57524 112 112 'webp-lossy.webp', 113 113 'webp-transparent.webp', 114 115 116 117 114 118 ); 115 119 … … 185 189 $files[] = 'webp-lossy.webp'; 186 190 $files[] = 'webp-transparent.webp'; 191 192 193 194 195 196 197 198 199 200 201 187 202 } 188 203 -
trunk/tests/phpunit/tests/image/resize.php
r54226 r57524 89 89 } 90 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 91 117 public function test_resize_larger() { 92 118 // image_resize() should refuse to make an image larger.
Note: See TracChangeset
for help on using the changeset viewer.