Skip to content

Commit e8e3cae

Browse files
authored
Merge branch 'development' into improve_lcp
2 parents b588e47 + 1f9168e commit e8e3cae

28 files changed

+398
-1245
lines changed

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
"install-wp-tests": "bash bin/install-wp-tests.sh wordpress_test root '' localhost latest"
5454
},
5555
"require": {
56-
"codeinwp/themeisle-sdk": "^3.3"
56+
"php": ">=7.4",
57+
"codeinwp/themeisle-sdk": "^3.3",
58+
"codeinwp/optimole-sdk": "^1.0"
5759
}
5860
}

composer.lock

Lines changed: 132 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inc/app_replacer.php

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
use Optimole\Sdk\Optimole;
4+
use Optimole\Sdk\ValueObject\Position;
5+
36
/**
47
* Class Optml_App_Replacer
58
*
@@ -615,9 +618,7 @@ protected function parse_dimensions_from_filename( $src ) {
615618
* @return string The optimized url.
616619
*/
617620
public function get_media_optimized_url( $url, $table_id, $width = 'auto', $height = 'auto', $resize = [] ) {
618-
$optimized_url = ( new Optml_Image( $url, ['width' => $width, 'height' => $height, 'resize' => $resize, 'quality' => $this->settings->get_numeric_quality()], $this->settings->get( 'cache_buster' ) ) )->get_url();
619-
$optimized_url = str_replace( $url, Optml_Media_Offload::KEYS['not_processed_flag'] . 'media_cloud' . '/' . Optml_Media_Offload::KEYS['uploaded_flag'] . $table_id . '/' . $url, $optimized_url );
620-
return $optimized_url;
621+
return str_replace( $url, Optml_Media_Offload::KEYS['not_processed_flag'] . 'media_cloud' . '/' . Optml_Media_Offload::KEYS['uploaded_flag'] . $table_id . '/' . $url, $this->get_optimized_image_url( $url, $width, $height, $resize ) );
621622
}
622623

623624
/**
@@ -630,4 +631,29 @@ public function get_media_optimized_url( $url, $table_id, $width = 'auto', $heig
630631
public function url_has_dam_flag( $url ) {
631632
return strpos( $url, Optml_Dam::URL_DAM_FLAG ) !== false;
632633
}
634+
635+
/**
636+
* Get the optimized image url for the image url.
637+
*
638+
* @param string $url The image URL.
639+
* @param mixed $width The image width.
640+
* @param mixed $height The image height.
641+
* @param array $resize The resize properties.
642+
*
643+
* @return string
644+
*/
645+
protected function get_optimized_image_url( $url, $width, $height, $resize = [] ) {
646+
$optimized_image = Optimole::image( $url, $this->settings->get( 'cache_buster' ) )
647+
->width( $width )
648+
->height( $height );
649+
650+
if ( is_array( $resize ) && ! empty( $resize['type'] ) ) {
651+
$optimized_image->resize( $resize['type'], $resize['gravity'] ?? Position::CENTER, $resize['enlarge'] ?? false );
652+
653+
}
654+
655+
$optimized_image->quality( $this->settings->to_accepted_quality( $this->settings->get_quality() ) );
656+
657+
return $optimized_image->getUrl();
658+
}
633659
}

inc/asset.php

Lines changed: 0 additions & 112 deletions
This file was deleted.

inc/asset_properties/minify.php

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)