@@ -121,16 +121,12 @@ function image_prioritizer_get_asset_path( string $src_path, ?string $min_path =
121
121
* Handles 'autoplay' and 'preload' attributes accordingly.
122
122
*
123
123
* @since 0.2.0
124
+ *
125
+ * @return string Lazy load script.
124
126
*/
125
- function image_prioritizer_get_lazy_load_script (): string {
126
- $ path = image_prioritizer_get_asset_path ( 'lazy-load.js ' );
127
- $ script = file_get_contents ( __DIR__ . '/ ' . $ path ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- It's a local filesystem path not a remote request.
128
-
129
- if ( false === $ script ) {
130
- return '' ;
131
- }
132
-
133
- return $ script ;
127
+ function image_prioritizer_get_video_lazy_load_script (): string {
128
+ $ path = image_prioritizer_get_asset_path ( 'lazy-load-video.js ' );
129
+ return (string ) file_get_contents ( __DIR__ . '/ ' . $ path ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- It's a local filesystem path not a remote request.
134
130
}
135
131
136
132
/**
@@ -139,30 +135,22 @@ function image_prioritizer_get_lazy_load_script(): string {
139
135
* Load the background image when it approaches the viewport using an IntersectionObserver.
140
136
*
141
137
* @since n.e.x.t
138
+ *
139
+ * @return string Lazy load script.
142
140
*/
143
141
function image_prioritizer_get_lazy_load_bg_image_script (): string {
144
- $ path = image_prioritizer_get_asset_path ( 'lazy-load-bg-image.js ' );
145
- $ script = file_get_contents ( __DIR__ . '/ ' . $ path ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- It's a local filesystem path not a remote request.
146
-
147
- if ( false === $ script ) {
148
- return '' ;
149
- }
150
-
151
- return $ script ;
142
+ $ path = image_prioritizer_get_asset_path ( 'lazy-load-bg-image.js ' );
143
+ return (string ) file_get_contents ( __DIR__ . '/ ' . $ path ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- It's a local filesystem path not a remote request.
152
144
}
153
145
154
146
/**
155
147
* Gets the stylesheet to lazy-load background images.
156
148
*
157
149
* @since n.e.x.t
150
+ *
151
+ * @return string Lazy load stylesheet.
158
152
*/
159
153
function image_prioritizer_get_lazy_load_bg_image_stylesheet (): string {
160
- $ path = image_prioritizer_get_asset_path ( 'lazy-load-bg-image.css ' );
161
- $ stylesheet = file_get_contents ( __DIR__ . '/ ' . $ path ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- It's a local filesystem path not a remote request.
162
-
163
- if ( false === $ stylesheet ) {
164
- return '' ;
165
- }
166
-
167
- return $ stylesheet ;
154
+ $ path = image_prioritizer_get_asset_path ( 'lazy-load-bg-image.css ' );
155
+ return (string ) file_get_contents ( __DIR__ . '/ ' . $ path ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- It's a local filesystem path not a remote request.
168
156
}
0 commit comments