Skip to content

Commit

Permalink
release: small fixes
Browse files Browse the repository at this point in the history
* Addressed an issue that caused slower performance for URLs not using the offloading feature.
  • Loading branch information
selul authored May 17, 2024
2 parents 3b5ed99 + 13750d9 commit 741af5d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions inc/app_replacer.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ abstract class Optml_App_Replacer {
* @var Optml_Settings $settings
*/
public $settings = null;
/**
* Cached offloading status.
*
* @var null|bool Offload status.
*/
public static $offload_enabled = null;
/**
* Defines if the dimensions should be limited when images are served.
*
Expand Down Expand Up @@ -356,6 +362,9 @@ function ( $strings = [] ) {
},
10
);
if ( self::$offload_enabled === null ) {
self::$offload_enabled = ( new Optml_Settings() )->is_offload_enabled();
}
}


Expand Down
3 changes: 3 additions & 0 deletions inc/url_replacer.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,9 @@ private function is_dam_url( $url ) {
private function is_offloaded_url( $source_url ) {
$attachment_id = 0;

if ( ! self::$offload_enabled ) {
return 0;
}
if ( strpos( $source_url, Optml_Media_Offload::KEYS['not_processed_flag'] ) !== false ) {
$attachment_id = (int) Optml_Media_Offload::get_attachment_id_from_url( $source_url );
} else {
Expand Down

0 comments on commit 741af5d

Please sign in to comment.