PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 1.9.8
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v1.9.8
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / classes / Media / Noop.php

Noop.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 1.9.8, at classes/Media/Noop.php

391 lines 8.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Imagify\Media;
3
4 defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
5
6 /**
7 * Fallback class for "media groups" (aka attachments).
8 *
9 * @since 1.9
10 * @author Grégory Viguier
11 */
12 class Noop implements MediaInterface {
13 use \Imagify\Deprecated\Traits\Media\NoopDeprecatedTrait;
14
15 /**
16 * Tell if the given entry can be accepted in the constructor.
17 * For example it can include `is_numeric( $id )` if the constructor accepts integers.
18 *
19 * @since 1.9
20 * @access public
21 * @author Grégory Viguier
22 *
23 * @param mixed $id Whatever.
24 * @return bool
25 */
26 public static function constructor_accepts( $id ) {
27 return false;
28 }
29
30 /**
31 * Get the media ID.
32 *
33 * @since 1.9
34 * @access public
35 * @author Grégory Viguier
36 *
37 * @return int
38 */
39 public function get_id() {
40 return 0;
41 }
42
43 /**
44 * Tell if the current media is valid.
45 *
46 * @since 1.9
47 * @access public
48 * @author Grégory Viguier
49 *
50 * @return bool
51 */
52 public function is_valid() {
53 return false;
54 }
55
56 /**
57 * Get the media context name.
58 *
59 * @since 1.9
60 * @access public
61 * @author Grégory Viguier
62 *
63 * @return string
64 */
65 public function get_context() {
66 return 'noop';
67 }
68
69 /**
70 * Get the media context instance.
71 *
72 * @since 1.9
73 * @access public
74 * @author Grégory Viguier
75 *
76 * @return ContextInterface
77 */
78 public function get_context_instance() {
79 return \Imagify\Context\Noop::get_instance();
80 }
81
82 /**
83 * Get the CDN instance.
84 *
85 * @since 1.9
86 * @access public
87 * @author Grégory Viguier
88 *
89 * @return bool|PushCDNInterface A PushCDNInterface instance. False if no CDN is used.
90 */
91 public function get_cdn() {
92 return false;
93 }
94
95
96 /** ----------------------------------------------------------------------------------------- */
97 /** ORIGINAL FILE =========================================================================== */
98 /** ----------------------------------------------------------------------------------------- */
99
100 /**
101 * Get the original file path, even if the file doesn't exist.
102 *
103 * @since 1.9
104 * @access public
105 * @author Grégory Viguier
106 *
107 * @return string|bool The file path. False on failure.
108 */
109 public function get_raw_original_path() {
110 return false;
111 }
112
113 /**
114 * Get the original media's path if the file exists.
115 *
116 * @since 1.9
117 * @access public
118 * @author Grégory Viguier
119 *
120 * @return string|bool The file path. False if it doesn't exist.
121 */
122 public function get_original_path() {
123 return false;
124 }
125
126
127 /** ----------------------------------------------------------------------------------------- */
128 /** FULL SIZE FILE ========================================================================== */
129 /** ----------------------------------------------------------------------------------------- */
130
131 /**
132 * Get the URL of the media’s full size file.
133 *
134 * @since 1.9.8
135 * @access public
136 * @author Grégory Viguier
137 *
138 * @return string|bool The file URL. False on failure.
139 */
140 public function get_fullsize_url() {
141 return false;
142 }
143
144 /**
145 * Get the path to the media’s full size file, even if the file doesn't exist.
146 *
147 * @since 1.9.8
148 * @access public
149 * @author Grégory Viguier
150 *
151 * @return string|bool The file path. False on failure.
152 */
153 public function get_raw_fullsize_path() {
154 return false;
155 }
156
157 /**
158 * Get the path to the media’s full size file if the file exists.
159 *
160 * @since 1.9.8
161 * @access public
162 * @author Grégory Viguier
163 *
164 * @return string|bool The file path. False if it doesn't exist.
165 */
166 public function get_fullsize_path() {
167 return false;
168 }
169
170
171 /** ----------------------------------------------------------------------------------------- */
172 /** BACKUP FILE ============================================================================= */
173 /** ----------------------------------------------------------------------------------------- */
174
175 /**
176 * Get the backup URL, even if the file doesn't exist.
177 *
178 * @since 1.9
179 * @access public
180 * @author Grégory Viguier
181 *
182 * @return string|bool The file URL. False on failure.
183 */
184 public function get_backup_url() {
185 return false;
186 }
187
188 /**
189 * Get the backup file path, even if the file doesn't exist.
190 *
191 * @since 1.9
192 * @access public
193 * @author Grégory Viguier
194 *
195 * @return string|bool The file path. False on failure.
196 */
197 public function get_raw_backup_path() {
198 return false;
199 }
200
201 /**
202 * Get the backup file path if the file exists.
203 *
204 * @since 1.9
205 * @access public
206 * @author Grégory Viguier
207 *
208 * @return string|bool The file path. False if it doesn't exist.
209 */
210 public function get_backup_path() {
211 return false;
212 }
213
214 /**
215 * Check if the media has a backup of the original file.
216 *
217 * @since 1.9
218 * @access public
219 * @author Grégory Viguier
220 *
221 * @return bool True if the media has a backup.
222 */
223 public function has_backup() {
224 return false;
225 }
226
227
228 /** ----------------------------------------------------------------------------------------- */
229 /** THUMBNAILS ============================================================================== */
230 /** ----------------------------------------------------------------------------------------- */
231
232 /**
233 * Create the media thumbnails.
234 *
235 * @since 1.9
236 * @access public
237 * @author Grégory Viguier
238 *
239 * @return bool|WP_Error True on success. A \WP_Error instance on failure.
240 */
241 public function generate_thumbnails() {
242 return new \WP_Error( 'invalid_media', __( 'This media is not valid.', 'imagify' ) );
243 }
244
245
246 /** ----------------------------------------------------------------------------------------- */
247 /** MEDIA DATA ============================================================================== */
248 /** ----------------------------------------------------------------------------------------- */
249
250 /**
251 * Tell if the current media type is supported.
252 *
253 * @since 1.9
254 * @access public
255 * @author Grégory Viguier
256 *
257 * @return bool
258 */
259 public function is_supported() {
260 return false;
261 }
262
263 /**
264 * Tell if the current media refers to an image, based on file extension.
265 *
266 * @since 1.9
267 * @access public
268 * @author Grégory Viguier
269 *
270 * @return bool Returns false in case it's an image but not in a supported format (bmp for example).
271 */
272 public function is_image() {
273 return false;
274 }
275
276 /**
277 * Tell if the current media refers to a pdf, based on file extension.
278 *
279 * @since 1.9
280 * @access public
281 * @author Grégory Viguier
282 *
283 * @return bool
284 */
285 public function is_pdf() {
286 return false;
287 }
288
289 /**
290 * Get the original file extension (if supported by Imagify).
291 *
292 * @since 1.9
293 * @access public
294 * @author Grégory Viguier
295 *
296 * @return string|null
297 */
298 public function get_extension() {
299 return '';
300 }
301
302 /**
303 * Get the original file mime type (if supported by Imagify).
304 *
305 * @since 1.9
306 * @access public
307 * @author Grégory Viguier
308 *
309 * @return string
310 */
311 public function get_mime_type() {
312 return '';
313 }
314
315 /**
316 * Get the file mime type + file extension (if the file is supported by Imagify).
317 * This test is ran against the original file.
318 *
319 * @since 1.9
320 * @access public
321 * @author Grégory Viguier
322 *
323 * @return array
324 */
325 public function get_allowed_mime_types() {
326 return imagify_get_mime_types( 'all' );
327 }
328
329 /**
330 * Tell if the current media has the required data (the data containing the file paths and thumbnails).
331 *
332 * @since 1.9
333 * @access public
334 * @author Grégory Viguier
335 *
336 * @return bool
337 */
338 public function has_required_media_data() {
339 return false;
340 }
341
342 /**
343 * Get the list of the files of this media, including the original file.
344 *
345 * @since 1.9
346 * @access public
347 * @author Grégory Viguier
348 *
349 * @return array {
350 * An array with the size names as keys ('full' is used for the original file), and arrays of data as values:
351 *
352 * @type string $path Absolute path to the file.
353 * @type int $width The file width.
354 * @type int $height The file height.
355 * @type string $mime-type The file mime type.
356 * }
357 */
358 public function get_media_files() {
359 return [];
360 }
361
362 /**
363 * If the media is an image, get its width and height.
364 *
365 * @since 1.9
366 * @access public
367 * @author Grégory Viguier
368 *
369 * @return array
370 */
371 public function get_dimensions() {
372 return [
373 'width' => 0,
374 'height' => 0,
375 ];
376 }
377
378 /**
379 * If the media is an image, update the dimensions in the database with the current file dimensions.
380 *
381 * @since 1.9
382 * @access public
383 * @author Grégory Viguier
384 *
385 * @return bool True on success. False on failure.
386 */
387 public function update_dimensions() {
388 return false;
389 }
390 }
391