This commit is contained in:
Mike Jolley 2018-01-25 17:03:54 +00:00
parent 6e83fcec50
commit ebde2d64fb
2 changed files with 9 additions and 13 deletions

View File

@ -7,9 +7,7 @@
* @since 3.3.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'WP_Async_Request', false ) ) {
include_once dirname( __FILE__ ) . '/libraries/wp-async-request.php';
@ -69,7 +67,7 @@ class WC_Regenerate_Images_Request extends WP_Background_Process {
return false;
}
update_option( 'woocommerce_last_image_regen_id', $item['attachment_id'] );
update_option( 'woocommerce_last_image_regen_id', $item['attachment_id'] );
if ( ! function_exists( 'wp_crop_image' ) ) {
include ABSPATH . 'wp-admin/includes/image.php';
@ -121,6 +119,7 @@ class WC_Regenerate_Images_Request extends WP_Background_Process {
/**
* Returns only WC image sizes.
*
* @param array $sizes Sizes to generate.
* @return array
*/
public function adjust_intermediate_image_sizes( $sizes ) {

View File

@ -4,16 +4,12 @@
*
* All functionality pertaining to regenerating product images in realtime.
*
* @category Images
* @package WooCommerce/Classes
* @author Automattic
* @version 3.3.0
* @since 3.3.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
defined( 'ABSPATH' ) || exit;
/**
* Regenerate Images Class
@ -31,7 +27,7 @@ class WC_Regenerate_Images {
* Init function
*/
public static function init() {
include_once( WC_ABSPATH . 'includes/class-wc-regenerate-images-request.php' );
include_once WC_ABSPATH . 'includes/class-wc-regenerate-images-request.php';
self::$background_process = new WC_Regenerate_Images_Request();
if ( apply_filters( 'woocommerce_resize_images', true ) && ! is_admin() ) {
@ -96,21 +92,22 @@ class WC_Regenerate_Images {
}
if ( ! function_exists( 'wp_crop_image' ) ) {
include( ABSPATH . 'wp-admin/includes/image.php' );
include ABSPATH . 'wp-admin/includes/image.php';
}
$wp_uploads = wp_upload_dir( null, false );
$wp_uploads_dir = $wp_uploads['basedir'];
$wp_uploads_url = $wp_uploads['baseurl'];
$original_image_file_path = get_attached_file( $attachment->ID );
$original_image_file_path = get_attached_file( $attachment->ID );
if ( ! file_exists( $original_image_file_path ) || ! getimagesize( $original_image_file_path ) ) {
return $image;
}
$info = pathinfo( $original_image_file_path );
$ext = $info['extension'];
$ext = $info['extension'];
list( $orig_w, $orig_h ) = getimagesize( $original_image_file_path );
// Get image size after cropping.
$image_size = wc_get_image_size( $size );