Make WordPress Core


Ignore:
Timestamp:
11/09/2020 01:16:54 PM (6 years ago)
Author:
johnbillion
Message:

Media: Restore the ability of WP_Image_Editor_Imagick->save() to create a missing directory when needed.

Props eemitch, mikeschroder, hellofromTonya, p00ya, johnbillion

Fixes #51665

File:
1 edited

Legend:

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

    r49233 r49542  
    742742                        }
    743743                } else {
     744                        $dir_name   = dirname( $filename );
     745                        $dir_exists = wp_mkdir_p( $dir_name );
     746
     747                        if ( ! $dir_exists ) {
     748                                return new WP_Error(
     749                                        'image_save_error',
     750                                        sprintf(
     751                                                /* translators: %s: Directory path. */
     752                                                __( 'Unable to create directory %s. Is its parent directory writable by the server?' ),
     753                                                esc_html( $dir_name )
     754                                        )
     755                                );
     756                        }
     757
    744758                        try {
    745759                                return $image->writeImage( $filename );
Note: See TracChangeset for help on using the changeset viewer.