Pass an attachment ID, not a file path, to _load_image_to_edit_path() from wp_crop_image(). This fixes handling of attachments that require url fopen to access the image.
Allow passing urls instead of just file paths to WP_Image_Editor_Imagick::load() and WP_Image_Editor_GD::load() so that attachments requiring URL fopen can be handled. see #6821 git-svn-id: https://develop.svn.wordpress.org/trunk@22538 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
5096f387d1
commit
5f92c0e7f4
|
@ -22,13 +22,15 @@
|
||||||
* @param string $dst_file Optional. The destination file to write to.
|
* @param string $dst_file Optional. The destination file to write to.
|
||||||
* @return string|WP_Error|false New filepath on success, WP_Error or false on failure.
|
* @return string|WP_Error|false New filepath on success, WP_Error or false on failure.
|
||||||
*/
|
*/
|
||||||
function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) {
|
function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) {
|
||||||
if ( is_numeric( $src_file ) ) { // Handle int as attachment ID
|
$src_file = $src;
|
||||||
$src_file = get_attached_file( $src_file );
|
if ( is_numeric( $src ) ) { // Handle int as attachment ID
|
||||||
|
$src_file = get_attached_file( $src );
|
||||||
|
|
||||||
if ( ! file_exists( $src_file ) ) {
|
if ( ! file_exists( $src_file ) ) {
|
||||||
// If the file doesn't exist, attempt a url fopen on the src link.
|
// If the file doesn't exist, attempt a url fopen on the src link.
|
||||||
// This can occur with certain file replication plugins.
|
// This can occur with certain file replication plugins.
|
||||||
$src_file = _load_image_to_edit_path( $src_file, 'full' );
|
$src_file = _load_image_to_edit_path( $src, 'full' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
|
||||||
if ( $this->image )
|
if ( $this->image )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if ( ! is_file( $this->file ) )
|
if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) )
|
||||||
return new WP_Error( 'error_loading_image', __('File doesn’t exist?'), $this->file );
|
return new WP_Error( 'error_loading_image', __('File doesn’t exist?'), $this->file );
|
||||||
|
|
||||||
// Set artificially high because GD uses uncompressed images in memory
|
// Set artificially high because GD uses uncompressed images in memory
|
||||||
|
|
|
@ -52,7 +52,7 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
|
||||||
if ( $this->image )
|
if ( $this->image )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if ( ! is_file( $this->file ) )
|
if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) )
|
||||||
return new WP_Error( 'error_loading_image', __('File doesn’t exist?'), $this->file );
|
return new WP_Error( 'error_loading_image', __('File doesn’t exist?'), $this->file );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue