PluginProbe
QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress / 2.0.0
QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress v2.0.0
4.1.2 4.1.1 4.1.0 4.0.1 4.0.0 3.3.1 3.3.0 trunk 1.0.0 2.0.0 2.1.0 3.0.0 3.1.0 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8
quickwebp / includes / vendor / intervention / image / src / Intervention / Image / File.php

File.php in QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress 2.0.0, at includes/vendor/intervention/image/src/Intervention/Image/File.php

93 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Intervention\Image;
4
5 class File
6 {
7 /**
8 * Mime type
9 *
10 * @var string
11 */
12 public $mime;
13
14 /**
15 * Name of directory path
16 *
17 * @var string
18 */
19 public $dirname;
20
21 /**
22 * Basename of current file
23 *
24 * @var string
25 */
26 public $basename;
27
28 /**
29 * File extension of current file
30 *
31 * @var string
32 */
33 public $extension;
34
35 /**
36 * File name of current file
37 *
38 * @var string
39 */
40 public $filename;
41
42 /**
43 * Sets all instance properties from given path
44 *
45 * @param string $path
46 */
47 public function setFileInfoFromPath($path)
48 {
49 $info = pathinfo($path);
50 $this->dirname = array_key_exists('dirname', $info) ? $info['dirname'] : null;
51 $this->basename = array_key_exists('basename', $info) ? $info['basename'] : null;
52 $this->extension = array_key_exists('extension', $info) ? $info['extension'] : null;
53 $this->filename = array_key_exists('filename', $info) ? $info['filename'] : null;
54
55 if (file_exists($path) && is_file($path)) {
56 $this->mime = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path);
57 }
58
59 return $this;
60 }
61
62 /**
63 * Get file size
64 *
65 * @return mixed
66 */
67 public function filesize()
68 {
69 $path = $this->basePath();
70
71 if (file_exists($path) && is_file($path)) {
72 return filesize($path);
73 }
74
75 return false;
76 }
77
78 /**
79 * Get fully qualified path
80 *
81 * @return string
82 */
83 public function basePath()
84 {
85 if ($this->dirname && $this->basename) {
86 return ($this->dirname .'/'. $this->basename);
87 }
88
89 return null;
90 }
91
92 }
93