|
17 | 17 | use OCP\Preview\IProviderV2; |
18 | 18 |
|
19 | 19 | /** |
20 | | - * This class provides functions to render and show thumbnails and previews of files |
| 20 | + * Public interface for discovering preview providers and generating file previews. |
| 21 | + * |
| 22 | + * ProviderClosure lazily resolves a preview provider and may return false if it |
| 23 | + * cannot be loaded. |
| 24 | + * |
21 | 25 | * @since 6.0.0 |
22 | 26 | * @psalm-type ProviderClosure = Closure():(IProviderV2|false) |
23 | 27 | */ |
24 | 28 | #[Consumable(since: '6.0.0')] |
25 | 29 | interface IPreview { |
26 | 30 | /** |
| 31 | + * Preview scaling mode that fills the requested dimensions. |
| 32 | + * |
27 | 33 | * @since 11.0.0 |
28 | 34 | */ |
29 | 35 | public const MODE_FILL = 'fill'; |
30 | 36 |
|
31 | 37 | /** |
| 38 | + * Preview scaling mode that covers the requested dimensions. |
| 39 | + * |
32 | 40 | * @since 11.0.0 |
33 | 41 | */ |
34 | 42 | public const MODE_COVER = 'cover'; |
35 | 43 |
|
36 | 44 | /** |
37 | | - * Get all providers |
38 | | - * @return array<string, list<ProviderClosure>> |
| 45 | + * Returns the registered preview providers grouped by supported mime-type regex. |
| 46 | + * |
| 47 | + * Each value is a list of closures that create preview providers when invoked, |
| 48 | + * not a list of already instantiated provider objects. |
| 49 | + * |
| 50 | + * The provider list is built on demand and is empty when previews are disabled. |
| 51 | + * |
| 52 | + * @return array<string, list<ProviderClosure>> Map of mime-type regex to provider-creating closures |
39 | 53 | * @since 8.1.0 |
40 | 54 | */ |
41 | 55 | public function getProviders(): array; |
@@ -64,17 +78,25 @@ public function hasProviders(): bool; |
64 | 78 | public function getPreview(File $file, int $width = -1, int $height = -1, bool $crop = false, string $mode = IPreview::MODE_FILL, ?string $mimeType = null, bool $cacheResult = true): ISimpleFile; |
65 | 79 |
|
66 | 80 | /** |
67 | | - * Returns true if the passed mime type is supported |
68 | | - * @param string $mimeType A glob |
| 81 | + * Returns whether any registered preview provider supports the given mime type. |
| 82 | + * |
| 83 | + * This checks the mime type against the providers' registered mime-type regexes. |
| 84 | + * It does not guarantee that preview generation will succeed for a specific file. |
| 85 | + * |
| 86 | + * @param string $mimeType Mime type string to test, for example "image/png" |
69 | 87 | * @since 6.0.0 |
70 | 88 | */ |
71 | 89 | public function isMimeSupported(string $mimeType = '*'): bool; |
72 | 90 |
|
73 | 91 | /** |
74 | | - * Check if a preview can be generated for a file |
| 92 | + * Returns whether a preview can currently be generated for the given file. |
| 93 | + * |
| 94 | + * This checks whether the effective mime type is supported, whether previews |
| 95 | + * are allowed on the file's mount, and whether at least one matching provider is |
| 96 | + * available for the file in the current environment. |
75 | 97 | * |
76 | 98 | * @param FileInfo $file |
77 | | - * @param string|null $mimeType To force a given mimetype for the file |
| 99 | + * @param string|null $mimeType Optional mime type override to use instead of $file->getMimeType() |
78 | 100 | * @since 8.0.0 |
79 | 101 | * @since 32.0.0 - isAvailable($mimeType) added the $mimeType argument to the signature |
80 | 102 | */ |
|
0 commit comments