PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.7.0
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.7.0
2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 1.1.0 All 77 releases
fluent-community / vendor / wpfluent / framework / src / WPFluent / Support / MediaUploader.php

MediaUploader.php in FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses 2.7.0, at vendor/wpfluent/framework/src/WPFluent/Support/MediaUploader.php

80 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCommunity\Framework\Support;
4
5 class MediaUploader
6 {
7 /**
8 * @var bool Whether to disable EXIF reading during upload
9 */
10 protected static bool $withoutExif = false;
11
12 /**
13 * @var bool Whether to disable generating
14 * intermediate image sizes during upload
15 */
16 protected static bool $withoutSizes = false;
17
18 /**
19 * Disable EXIF reading during upload.
20 *
21 * @return static
22 */
23 public static function withoutExif()
24 {
25 static::$withoutExif = true;
26 return new static;
27 }
28
29 /**
30 * Disable generating intermediate image sizes during upload.
31 *
32 * @return static
33 */
34 public static function withoutSizes()
35 {
36 static::$withoutSizes = true;
37 return new static;
38 }
39
40 /**
41 * Disable both EXIF reading and image sizes during upload.
42 *
43 * @return static
44 */
45 public static function withoutExifAndSizes()
46 {
47 static::$withoutExif = true;
48 static::$withoutSizes = true;
49 return new static;
50 }
51
52 /**
53 * Upload a local file array or remote URL, optionally disabling EXIF or image sizes.
54 *
55 * @param array|string $resource File array from $_FILES or remote URL
56 * @param int $postId Optional post ID to attach media to
57 * @param string|null $filename Optional filename for remote URLs
58 *
59 * @return array
60 */
61 public static function upload($resource, $postId = 0, $filename = null)
62 {
63 $media = new Media();
64
65 if (static::$withoutExif) {
66 $media->withoutExif();
67 }
68
69 if (static::$withoutSizes) {
70 $media->withoutSizes();
71 }
72
73 // Reset flags so they don't persist between calls
74 static::$withoutExif = false;
75 static::$withoutSizes = false;
76
77 return $media->upload($resource, $postId, $filename);
78 }
79 }
80