diff --git a/README.txt b/README.txt index d339828..045fc72 100644 --- a/README.txt +++ b/README.txt @@ -107,6 +107,7 @@ Fixed: * Notices getting injected into plugin navigation * Do not expose internal methods to WP CLI commands * WP CLI command only processing the first 10 images +* Auto resize feature using incorrect descriptors = 1.6.0 - 12.11.2023 = diff --git a/app/class-cli.php b/app/class-cli.php index 49b936a..8658711 100644 --- a/app/class-cli.php +++ b/app/class-cli.php @@ -126,20 +126,20 @@ private function offload_all() { $progress = WP_CLI\Utils\make_progress_bar( __( 'Offloading images', 'cf-images' ), $images->found_posts ); foreach ( $images->posts as $attachment ) { - $metadata = wp_get_attachment_metadata( $attachment->ID ); + $metadata = wp_get_attachment_metadata( $attachment ); if ( false === $metadata ) { $errors[] = sprintf( /* translators: %d - attachment ID */ esc_html__( 'Image metadata not found (attachment ID: %d).', 'cf-images' ), - $attachment->ID + $attachment ); } else { - ( new Media() )->upload_image( $metadata, $attachment->ID ); + ( new Media() )->upload_image( $metadata, $attachment ); if ( is_wp_error( Core::get_error() ) ) { $errors[] = sprintf( /* translators: %1$s - error message, %2$d - attachment ID */ esc_html__( '%1$s (attachment ID: %2$d).', 'cf-images' ), esc_html( Core::get_error()->get_error_message() ), - $attachment->ID + $attachment ); } } diff --git a/app/modules/class-auto-resize.php b/app/modules/class-auto-resize.php index ac76f2a..83896ea 100644 --- a/app/modules/class-auto-resize.php +++ b/app/modules/class-auto-resize.php @@ -80,7 +80,7 @@ public function add_srcset_to_image( string $image_dom, Image $image ): string { break; } - $srcset[] = $image->get_cf_image() . 'w=' . $size . ' ' . $size . 'px'; + $srcset[] = $image->get_cf_image() . 'w=' . $size . ' ' . $size . 'w'; } unset( $size ); @@ -90,7 +90,7 @@ public function add_srcset_to_image( string $image_dom, Image $image ): string { } // Add the original image to the srcset. - $srcset[] = $image->get_cf_image() . 'w=' . $image->get_width() . ' ' . $image->get_width() . 'px'; + $srcset[] = $image->get_cf_image() . 'w=' . $image->get_width() . ' ' . $image->get_width() . 'w'; // Check if there is already a 'sizes' attribute. $sizes = strpos( $image_dom, ' sizes=' );