Skip to content

Commit

Permalink
Remove all next-gen images version
Browse files Browse the repository at this point in the history
  • Loading branch information
jeawhanlee committed Feb 21, 2024
1 parent 38c9211 commit 1720719
Showing 1 changed file with 8 additions and 29 deletions.
37 changes: 8 additions & 29 deletions classes/Optimization/Process/AbstractProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,6 @@ abstract class AbstractProcess implements ProcessInterface {
*/
protected $format;

/**
* An array of valid extensions.
*
* @var array
* @since 2.2
*/
protected $extensions = [];

/**
* The constructor.
*
Expand All @@ -132,10 +124,6 @@ public function __construct( $id ) {

$this->filesystem = \Imagify_Filesystem::get_instance();
$this->format = $this->get_current_format();
$this->extensions = [
static::AVIF_SUFFIX => 'avif',
static::WEBP_SUFFIX => 'webp',
];
}

/**
Expand Down Expand Up @@ -1537,16 +1525,16 @@ protected function delete_nextgen_file( $file_path ) {
return new WP_Error( 'no_path', __( 'Path to non-next-gen file not provided.', 'imagify' ) );
}

$next_gen_ext = $this->get_format_extension( $this->format );
$next_gen_file = new File( $file_path );
$this->delete_file( $next_gen_file->get_path_to_nextgen( $next_gen_ext ) );
$extensions = imagify_nextgen_images_formats();

// Delete other next-gen images if they exist.
foreach ( $this->extensions as $extension ) {
if ( $next_gen_ext === $extension ) {
continue;
}
if ( empty( $extensions ) ) {
return;
}

$next_gen_file = new File( $file_path );

// Delete next-gen images.
foreach ( $extensions as $extension ) {
$this->delete_file( $next_gen_file->get_path_to_nextgen( $extension ) );
}
}
Expand Down Expand Up @@ -1613,15 +1601,6 @@ public function get_current_format() {
return $this->get_option( 'convert_to_avif' ) ? static::AVIF_SUFFIX : static::WEBP_SUFFIX;
}

/**
* Get specific format extension.
*
* @param string $format nextgen image format.
*/
private function get_format_extension( $format ) {
return isset( $this->extensions[ $format ] ) ? $this->extensions[ $format ] : '';
}

/**
* Tell if a thumbnail size is an "Imagify Next-Gen" size.
*
Expand Down

0 comments on commit 1720719

Please sign in to comment.