Uploads final readonly class
Minn\Media\Uploads · public/minn/src/Minn/Media/Uploads.php · 135 lines
The uploads directory: paths, URLs, the allowed types, and landing a file.
Constants and properties
| const | MIMES = array ( 'png' => 'image/png', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'gif' => 'image/gif', 'webp' => 'image/webp', 'pdf' => 'application/pdf', 'txt' => 'text/plain', 'mp4' => 'video/mp4', 'mp3' => 'audio/mpeg', 'zip' => 'application/zip', ) | extension => canonical mime |
| private | readonly Minn\Front\Permalinks $permalinks | Promoted from the constructor. |
| private | readonly string $baseDir | Promoted from the constructor. |
Public
| new | __construct(Minn\Front\Permalinks $permalinks, string $baseDir)# | |||||||
| method | baseDir(): string# | The uploads directory on disk. | ||||||
| method | baseUrl(): string# | The uploads directory's URL. | ||||||
| method | urlFor(string $relativePath): string# | The URL of a file by its relative path. | ||||||
| method | pathFor(string $relativePath): string# | The path of a file by its relative path. | ||||||
| static | sanitizeName(string $filename): string# | A safe file name: one extension. Every dot-separated part between the base and the last extension that is not itself an allowed extension is joined with an underscore, so "shell.php.png" lands as "shell_php.png" and no handler can be talked into running it. | ||||||
| method | relativeOf(string $absolutePath): ?string# | A stored file's path relative to the uploads folder, or null for a file outside it. | ||||||
| static | attachmentFiles(string $file, array $meta, ?array $backupSizes): array# | Every file an attachment owns, in deletion order: the legacy thumb, each sub-size, the original image, the backup sizes, then the file itself.
@return list<string> absolute paths, unique, only the main file checked for existence | ||||||
| static | layout(string $uploadPath, string $uploadUrlPath, string $siteUrl, string $contentDir, string $contentUrl, string $abspath, bool $yearMonth, string $time): array# | Where uploads live, from the site's options: the default folder under wp-content, a relative upload_path under ABSPATH, or an absolute one; the URL likewise, with year/month subfolders when the site asks. @return array{path: string, url: string, subdir: string, basedir: string, baseurl: string, error: false} |
Nothing matches.