Skip to content

Commit

Permalink
adding optimizations for webP check (#446)
Browse files Browse the repository at this point in the history
* adding optimizations for webP check

* fixing condition
  • Loading branch information
iruzevic authored Jan 7, 2025
1 parent 9e53e47 commit bf4ee92
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/).

## [9.3.2]

### Updated

- Updated `isWebPMediaUsed` method to use static variable so the check is done only once.

## [9.3.1]

### Fixed
Expand Down Expand Up @@ -793,6 +799,7 @@ Init setup
- Gutenberg Blocks Registration.
- Assets Manifest data.

[9.3.2]: https://github.com/infinum/eightshift-libs/compare/9.3.1...9.3.2
[9.3.1]: https://github.com/infinum/eightshift-libs/compare/9.3.0...9.3.1
[9.3.0]: https://github.com/infinum/eightshift-libs/compare/9.2.2...9.3.0
[9.2.2]: https://github.com/infinum/eightshift-libs/compare/9.2.1...9.2.2
Expand Down
8 changes: 7 additions & 1 deletion src/Helpers/MediaTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ public static function getWebPMedia(string $path, array $allowd = AbstractMedia:
*/
public static function isWebPMediaUsed(): bool
{
return (bool) \get_option(UseWebPMediaCli::USE_WEBP_MEDIA_OPTION_NAME, true);
static $isWebPMediaUsed = null;

if ($isWebPMediaUsed === null) {
$isWebPMediaUsed = (bool) \get_option(UseWebPMediaCli::USE_WEBP_MEDIA_OPTION_NAME, false);
}

return $isWebPMediaUsed;
}

/**
Expand Down

0 comments on commit bf4ee92

Please sign in to comment.