[wp-trac] [WordPress Trac] #62729: stream_preview_image() should stream with right mime type, if filter _load_image_to_edit_path change file with different mime type
WordPress Trac
noreply at wordpress.org
Mon Jan 27 11:21:35 UTC 2025
#62729: stream_preview_image() should stream with right mime type, if filter
_load_image_to_edit_path change file with different mime type
--------------------------------------+------------------------------
Reporter: Hrohh | Owner: pbearne
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: Awaiting Review
Component: Post Thumbnails | Version: 6.7.1
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses:
--------------------------------------+------------------------------
Comment (by Hrohh):
I have nasty fix
{{{#!php
<?php
// bug in wp_stream_image in image-edit.php, bad mime type
add_filter( 'image_editor_save_pre',
'core_thumbnail_generator_image_editor_save_pre', 10, 2 );
function core_thumbnail_generator_image_editor_save_pre( $image,
$attachment_id ) {
if ( ! ( did_action( 'wp_ajax_image-editor' ) || did_action(
'wp_ajax_imgedit-preview' ) ) )
return $image;
$attachment = get_post( $attachment_id );
if ( in_array( $attachment->post_mime_type, array( 'image/jpeg',
'image/png', 'image/apng', 'image/gif', 'image/bmp', 'image/webp',
'image/avif' ) ) )
return $image;
if ( is_wp_error( $image->stream() ) ) {
return false;
}
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62729#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list