WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/20/2020 02:35:10 PM (11 months ago)
Author:
mikeschroder
Message:

Media: Support Stream Wrappers In WP_Image_Editor_Imagick

Since WP_Image_Editor's introduction, stream wrappers have functioned in WP_Image_Editor_GD, but haven't been properly supported in WP_Image_Editor_Imagick.

  • Detects stream wrappers and uses file_put_contents() along with Imagick::read/getImageBlob() for handling when necessary.
  • Introduces private method, WP_Image_Editor_Imagick::write_image to handle detection and proper saving.
  • Introduces WP_Test_Stream class for testing stream wrappers, along with new tests for Imagick's stream handling and a stream filename test.

Adds requirement for Imagick::readImageBlob(), available in Imagick >= 2.0.0, which aligns with the current requirement of Imagick >= 2.2.0.

Props p00ya, calin, joemcgill, pputzer, jimyaghi, mikeschroder.
Fixes #42663.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-image-editor.php

    r48586 r49230  
    366366
    367367        if ( ! is_null( $dest_path ) ) {
    368             $_dest_path = realpath( $dest_path );
    369             if ( $_dest_path ) {
    370                 $dir = $_dest_path;
     368            if ( ! wp_is_stream( $dest_path ) ) {
     369                $_dest_path = realpath( $dest_path );
     370                if ( $_dest_path ) {
     371                    $dir = $_dest_path;
     372                }
     373            } else {
     374                $dir = $dest_path;
    371375            }
    372376        }
Note: See TracChangeset for help on using the changeset viewer.