Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 3rd-party compatibilities for multiple next-gen formats #836

Merged
merged 34 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f3c600a
Closes #763: AVIF support: UI (#769)
Miraeld Jan 3, 2024
fc76130
Closes #772: Changed webp to avif and slight modification to UI (#780)
Khadreal Jan 15, 2024
ec0bf15
Closes #766: Add avif format to picture element (#781)
jeawhanlee Jan 16, 2024
188264f
Add league/container, event-manager to composer and mozart (#782)
Khadreal Jan 18, 2024
1dc3a71
Add AVIF Rewrite rules (#774)
Miraeld Jan 18, 2024
0e8a3b1
AVIF settings update (#775)
Miraeld Jan 19, 2024
0a8f547
Add filter for nextgen image format #777 (#783)
Khadreal Jan 19, 2024
994c4eb
Feature/778 avif bulk generate (#784)
Khadreal Jan 23, 2024
de6dc98
Change methods name (#785)
Khadreal Jan 25, 2024
b396de2
Update WP background processing and Action Scheduler (#786)
remyperona Jan 29, 2024
19f6e4f
Fixes #791 Update texts related to WebP and Next-Gen (#800)
remyperona Feb 9, 2024
5d431cf
Merge branch 'develop' into feature/avif
remyperona Feb 14, 2024
fc23358
Fixes Container, Event Manager, CLI & Rewrite rules for AVIF (#797)
remyperona Feb 19, 2024
29f4bfb
Fixes #789 Fix error displayed when using generate missing next-gen v…
remyperona Feb 22, 2024
6c286ea
Fixes #788 Generate next-gen formats on image upload (#809)
remyperona Feb 22, 2024
2d98bbc
Closes #796: Auto generation of AVIF on save (#806)
Miraeld Feb 22, 2024
4502844
Closes #790, #792, #803: Delete/Generate next-gen in media not workin…
jeawhanlee Feb 22, 2024
6a64753
coding standards fixes
remyperona Feb 22, 2024
770c25f
update some occurences of webp to next-gen
remyperona Feb 22, 2024
0103815
update text
remyperona Feb 24, 2024
a62dc23
update minified file
remyperona Feb 26, 2024
e357b67
Fixes #815 Skip image deletion if returned path value is false (#819)
remyperona Feb 27, 2024
324c4fa
Closes #796: Auto AVIF Convertion on settings save (#811)
Miraeld Feb 28, 2024
4677279
Closes #822: The filter to enable webP along with AVIF is not working…
jeawhanlee Feb 28, 2024
85edeba
Fixes #826 Only generate missing next-gen when enabling AVIF option (…
remyperona Feb 29, 2024
f673ed2
Apply nginx rules for next gen images (#824)
wordpressfan Mar 1, 2024
6a7f2f3
Fix data for optimized medias without next-gen versions (#820)
remyperona Mar 1, 2024
22e543c
Fix/830 bulk optimisation (#832)
Khadreal Mar 4, 2024
610acc3
Fix generation of next gen images with first settings save of avif op…
wordpressfan Mar 4, 2024
088230c
update version to 2.2-alpha1
remyperona Mar 4, 2024
20b61ca
update author
remyperona Mar 4, 2024
2ff1bfc
update readme
remyperona Mar 4, 2024
581e808
update 3rd-party compatibilities for multiple next-gen formats
remyperona Mar 4, 2024
5e3db8d
Merge branch 'develop' into fix/3rd-party-next-gen
remyperona Mar 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions inc/3rd-party/WooCommerce/class-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ class WooCommerce {
* @return void
*/
public function init() {
add_action( 'woocommerce_single_product_summary', [ $this, 'variable_products_webp_compat' ] );
add_action( 'woocommerce_single_product_summary', [ $this, 'variable_products_nextgen_compat' ] );
}

/**
* Add Variable Products Webp Compatibility.
* Add Variable Products Next-gen images Compatibility.
*
* @since 1.10.0
*
* @return void
*/
public function variable_products_webp_compat() {
public function variable_products_nextgen_compat() {
global $product;

if ( ! isset( $product ) || ! $product->is_type( 'variable' ) ) {
Expand Down
5 changes: 2 additions & 3 deletions inc/3rd-party/amp/amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
*/
if ( function_exists( 'is_amp_endpoint' ) ) :

add_filter( 'imagify_allow_picture_tags_for_webp', 'imagify_amp_disable_picture_on_endpoint' );
add_filter( 'imagify_allow_picture_tags_for_nextgen', 'imagify_amp_disable_picture_on_endpoint' );
/**
* Do not use <picture> tags in AMP pages.
*
* @since 1.9
* @author Grégory Viguier
* @since 1.9
*
* @param bool $allow True to allow the use of <picture> tags (default). False to prevent their use.
* @return bool
Expand Down
40 changes: 15 additions & 25 deletions inc/3rd-party/enable-media-replace/classes/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
use Imagify_Enable_Media_Replace_Deprecated;
use Imagify_Filesystem;

defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );

/**
* Compat class for Enable Media Replace plugin.
*
Expand Down Expand Up @@ -40,12 +38,12 @@ class Main extends Imagify_Enable_Media_Replace_Deprecated {
protected $old_backup_path;

/**
* List of paths to the old WebP files.
* List of paths to the old next-gen files.
*
* @var array
* @since 1.9.8
*/
protected $old_webp_paths = [];
protected $old_nextgen_paths = [];

/**
* Launch the hooks before the files and data are replaced.
Expand Down Expand Up @@ -84,29 +82,26 @@ public function init( $args = [] ) {
}

/**
* Keep track of existing WebP files.
* Keep track of existing next-gen files.
*
* Whether the user chooses to rename the files or not, we will need to delete the current WebP files before creating new ones:
* Whether the user chooses to rename the files or not, we will need to delete the current next-gen files before creating new ones:
* - Rename the files: the old ones must be removed, they are useless now.
* - Do not rename the files: the thumbnails may still get new names because of the suffix containing the image dimensions, which may differ (for example when thumbnails are scaled, not cropped).
* In this last case, the thumbnails with the old dimensions are removed from the drive and from the WP’s post meta, so there is no need of keeping orphan WebP files that would stay on the drive for ever, even after the attachment is deleted from WP.
* In this last case, the thumbnails with the old dimensions are removed from the drive and from the WP’s post meta, so there is no need of keeping orphan next-gen files that would stay on the drive for ever, even after the attachment is deleted from WP.
*/
foreach ( $this->process->get_media()->get_media_files() as $media_file ) {
$this->old_webp_paths[] = imagify_path_to_webp( $media_file['path'] );
foreach ( [ 'avif', 'webp' ] as $format ) {
$this->old_nextgen_paths[] = imagify_path_to_nextgen( $media_file['path'], $format );
}
}

// Delete the old backup file and old WebP files.
// Delete the old backup file and old next-gen files.
add_action( 'imagify_before_auto_optimization', [ $this, 'delete_backup' ] );
add_action( 'imagify_not_optimized_attachment_updated', [ $this, 'delete_backup' ] );
}


/** ----------------------------------------------------------------------------------------- */
/** HOOKS =================================================================================== */
/** ----------------------------------------------------------------------------------------- */

/**
* Delete previous backup file and WebP files.
* Delete previous backup file and next-gen files.
* This is done after the images have been already replaced by Enable Media Replace.
*
* @since 1.8.4
Expand All @@ -126,19 +121,14 @@ public function delete_backup( $media_id ) {
$this->old_backup_path = false;
}

if ( ! empty( $this->old_webp_paths ) ) {
// Delete old WebP files.
$this->old_webp_paths = array_filter( $this->old_webp_paths, [ $filesystem, 'exists' ] );
array_map( [ $filesystem, 'delete' ], $this->old_webp_paths );
$this->old_webp_paths = [];
if ( ! empty( $this->old_nextgen_paths ) ) {
// Delete old next-gen files.
$this->old_nextgen_paths = array_filter( $this->old_nextgen_paths, [ $filesystem, 'exists' ] );
array_map( [ $filesystem, 'delete' ], $this->old_nextgen_paths );
$this->old_nextgen_paths = [];
}
}


/** ----------------------------------------------------------------------------------------- */
/** TOOLS =================================================================================== */
/** ----------------------------------------------------------------------------------------- */

/**
* Get the optimization process corresponding to the current media.
*
Expand Down
8 changes: 4 additions & 4 deletions inc/3rd-party/regenerate-thumbnails/classes/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,19 @@ public function launch_async_optimization( $metadata, $media_id ) {
/**
* Optimize the sizes that have been regenerated.
*/
// If the media has WebP versions, recreate them for the sizes that have been regenerated.
// If the media has next-gen versions, recreate them for the sizes that have been regenerated.
$data = $process->get_data();
$optimization_data = $data->get_optimization_data();

if ( ! empty( $optimization_data['sizes'] ) ) {
foreach ( $optimization_data['sizes'] as $size_name => $size_data ) {
$non_webp_size_name = $process->is_size_next_gen( $size_name );
$non_nextgen_size_name = $process->is_size_next_gen( $size_name );

if ( ! $non_webp_size_name || ! isset( $sizes[ $non_webp_size_name ] ) ) {
if ( ! $non_nextgen_size_name || ! isset( $sizes[ $non_nextgen_size_name ] ) ) {
continue;
}

// Add the WebP size.
// Add the next-gen size.
$sizes[ $size_name ] = [];
}
}
Expand Down
Loading