Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2220,6 +2220,15 @@ private function validate_image_dimensions( int $width, int $height, string $ima
return true;
}

/*
* 'animated_video_poster' companion: a static poster image for the
* converted video. It is a real image (so it has positive dimensions)
* but is not a registered sub-size, so it has no dimension constraint.
*/
if ( 'animated_video_poster' === $image_size ) {
return true;
}

// Regular image sizes: validate against registered size constraints.
$registered_sizes = wp_get_registered_image_subsizes();

Expand Down Expand Up @@ -2367,12 +2376,19 @@ public function sideload_item( WP_REST_Request $request ) {
$image_size = $request['image_size'];

/*
* Validate raster sub-sizes before storing them. Source-format companion
* originals (e.g. a HEIC or JXL kept next to its JPEG derivative) are
* exempt: their dimensions are neither validated nor recorded, and the
* source format may not be readable by wp_getimagesize() at all.
* Validate raster sub-sizes before storing them. Two companion sizes
* are exempt because wp_getimagesize() may not be able to read the
* file at all: the 'animated_video' companion of an animated GIF is a
* video (MP4/WebM), and a source-format original (e.g. a HEIC or JXL
* kept next to its JPEG derivative) may be an unreadable format. Their
* dimensions are neither validated nor recorded. The
* 'animated_video_poster' companion is a real image, so it is still
* read and rejected if unreadable; validate_image_dimensions() skips
* only the registered-size constraint for it.
*/
if ( self::IMAGE_SIZE_SOURCE_ORIGINAL !== $image_size ) {
$skip_dimension_read = in_array( $image_size, array( self::IMAGE_SIZE_SOURCE_ORIGINAL, 'animated_video' ), true );

if ( ! $skip_dimension_read ) {
Comment thread
adamsilverstein marked this conversation as resolved.
/*
* Read the dimensions up front. A file whose dimensions cannot be
* read is corrupted or an unsupported format and must be rejected
Expand Down
Loading