1 | <?php |
||
2 | /** |
||
3 | * ImageOptimize plugin for Craft CMS |
||
4 | * |
||
5 | * Automatically optimize images after they've been transformed |
||
6 | * |
||
7 | * @link https://nystudio107.com |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
8 | * @copyright Copyright (c) 2020 nystudio107 |
||
0 ignored issues
–
show
|
|||
9 | */ |
||
0 ignored issues
–
show
|
|||
10 | |||
11 | namespace nystudio107\imageoptimize\utilities; |
||
12 | |||
13 | use Craft; |
||
14 | |||
15 | use craft\base\Utility; |
||
16 | use nystudio107\imageoptimize\ImageOptimize; |
||
17 | |||
18 | /** |
||
19 | * ImageOptimize Utility |
||
20 | * |
||
21 | * @author nystudio107 |
||
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
![]() |
|||
22 | * @package ImageOptimize |
||
0 ignored issues
–
show
|
|||
23 | * @since 1.0.0 |
||
0 ignored issues
–
show
|
|||
24 | */ |
||
0 ignored issues
–
show
|
|||
25 | class ImageOptimizeUtility extends Utility |
||
26 | { |
||
27 | // Static |
||
28 | // ========================================================================= |
||
29 | |||
30 | /** |
||
0 ignored issues
–
show
|
|||
31 | * @inheritdoc |
||
32 | */ |
||
0 ignored issues
–
show
|
|||
33 | public static function displayName(): string |
||
34 | { |
||
35 | return Craft::t('image-optimize', 'ImageOptimize Info'); |
||
36 | } |
||
37 | |||
38 | /** |
||
0 ignored issues
–
show
|
|||
39 | * @inheritdoc |
||
40 | */ |
||
0 ignored issues
–
show
|
|||
41 | public static function id(): string |
||
42 | { |
||
43 | return 'imageoptimize-image-optimize-utility'; |
||
44 | } |
||
45 | |||
46 | /** |
||
0 ignored issues
–
show
|
|||
47 | * @inheritdoc |
||
48 | */ |
||
0 ignored issues
–
show
|
|||
49 | public static function iconPath(): ?string |
||
50 | { |
||
51 | return Craft::getAlias("@nystudio107/imageoptimize/icon-mask.svg"); |
||
0 ignored issues
–
show
|
|||
52 | } |
||
53 | |||
54 | /** |
||
0 ignored issues
–
show
|
|||
55 | * @inheritdoc |
||
56 | */ |
||
0 ignored issues
–
show
|
|||
57 | public static function badgeCount(): int |
||
58 | { |
||
59 | return 0; |
||
60 | } |
||
61 | |||
62 | /** |
||
0 ignored issues
–
show
|
|||
63 | * @inheritdoc |
||
64 | */ |
||
0 ignored issues
–
show
|
|||
65 | public static function contentHtml(): string |
||
66 | { |
||
67 | $imageProcessors = ImageOptimize::$plugin->optimize->getActiveImageProcessors(); |
||
68 | $variantCreators = ImageOptimize::$plugin->optimize->getActiveVariantCreators(); |
||
69 | |||
70 | return Craft::$app->getView()->renderTemplate( |
||
71 | 'image-optimize/_components/utilities/ImageOptimizeUtility_content', |
||
72 | [ |
||
73 | 'imageProcessors' => $imageProcessors, |
||
74 | 'variantCreators' => $variantCreators, |
||
75 | ] |
||
76 | ); |
||
77 | } |
||
78 | } |
||
79 |