PluginProbe ʕ •ᴥ•ʔ
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF / trunk
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF vtrunk
2.0.5 trunk 1.3.7 1.4.0 1.4.1 1.4.2 1.4.6 1.5.0 1.5.3 1.5.6 1.5.8 1.6.5 1.6.6 1.6.9 1.7.0 1.7.4 1.8.1 1.8.2 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4
robin-image-optimizer / libs / addons / includes / classes / models / class.folders-extra-data.php
robin-image-optimizer / libs / addons / includes / classes / models Last commit date
class.folders-extra-data.php 5 months ago class.nextgen-extra-data.php 5 months ago
class.folders-extra-data.php
262 lines
1 <?php
2
3 // Exit if accessed directly
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 /**
9 * Class WRIO_Nextgen_Extra_Data is a DTO model for `nextgen` post type used for `extra_data`
10 * property in RIO_Process_Queue.
11 *
12 * @see RIO_Process_Queue::$extra_data for further information
13 */
14 class WRIO_CF_Image_Extra_Data extends RIO_Base_Extra_Data {
15
16 /**
17 * @var string путь к файлу относительно папки
18 */
19 protected $file_path = null;
20
21 /**
22 * @var string тип ошибки
23 */
24 protected $error = null;
25
26 /**
27 * @var string текст сообщения об ошибке
28 */
29 protected $error_msg = null;
30
31 /**
32 * @var int оригинальный размер основного файла
33 */
34 protected $original_main_size = null;
35
36 /**
37 * @var int оптимизированный размер основного файла
38 */
39 protected $optimized_main_size = null;
40
41 /**
42 * @var array ответ от сервера оптимизации по основному файлу
43 */
44 protected $main_optimized_data = null;
45
46 /**
47 * @var string путь к папке относительно корня WP
48 */
49 protected $folder_relative_path = null;
50
51 /**
52 * @var int размер основного изображения
53 */
54 protected $webp_main_size = null;
55
56 /**
57 * get_file_path
58 *
59 * @return string
60 */
61 public function get_file_path() {
62 return $this->file_path;
63 }
64
65 /**
66 * set_file_path
67 *
68 * @param string $file_path
69 *
70 * @return void
71 */
72 public function set_file_path( $file_path ) {
73 $this->file_path = $file_path;
74 }
75
76 /**
77 * get_error
78 *
79 * @return string
80 */
81 public function get_error() {
82 return $this->error;
83 }
84
85 /**
86 * set_error
87 *
88 * @param string $error
89 *
90 * @return void
91 */
92 public function set_error( $error ) {
93 $this->error = $error;
94 }
95
96 /**
97 * get_error_msg
98 *
99 * @return string
100 */
101 public function get_error_msg() {
102 return $this->error_msg;
103 }
104
105 /**
106 * set_error_msg
107 *
108 * @param string $error_msg
109 *
110 * @return void
111 */
112 public function set_error_msg( $error_msg ) {
113 $this->error_msg = $error_msg;
114 }
115
116 /**
117 * get_original_main_size
118 *
119 * @return int
120 */
121 public function get_original_main_size() {
122 return $this->original_main_size;
123 }
124
125 /**
126 * set_original_main_size
127 *
128 * @param int $original_main_size
129 *
130 * @return void
131 */
132 public function set_original_main_size( $original_main_size ) {
133 $this->original_main_size = $original_main_size;
134 }
135
136 /**
137 * get_optimized_main_size
138 *
139 * @return int
140 */
141 public function get_optimized_main_size() {
142 return $this->optimized_main_size;
143 }
144
145 /**
146 * set_optimized_main_size
147 *
148 * @param int $optimized_main_size
149 *
150 * @return void
151 */
152 public function set_optimized_main_size( $optimized_main_size ) {
153 $this->optimized_main_size = $optimized_main_size;
154 }
155
156 /**
157 * get_main_optimized_data
158 *
159 * @return array
160 */
161 public function get_main_optimized_data() {
162 return (array) $this->main_optimized_data;
163 }
164
165 /**
166 * set_main_optimized_data
167 *
168 * @param array $main_optimized_data
169 *
170 * @return void
171 */
172 public function set_main_optimized_data( $main_optimized_data ) {
173 $this->main_optimized_data = $main_optimized_data;
174 }
175
176 /**
177 * get_folder_relative_path
178 *
179 * @return string
180 */
181 public function get_folder_relative_path() {
182 return $this->folder_relative_path;
183 }
184
185 /**
186 * set_folder_relative_path
187 *
188 * @param string $folder_relative_path
189 *
190 * @return void
191 */
192 public function set_folder_relative_path( $folder_relative_path ) {
193 $this->folder_relative_path = $folder_relative_path;
194 }
195
196 /**
197 * Возвращает абсолютный путь к папке
198 *
199 * @return string
200 */
201 public function get_folder_absolute_path() {
202 $relative_path = $this->get_folder_relative_path();
203 // Use get_home_path() to match how real_path_to_relative() calculates relative paths
204 $base_path = is_main_site() ? get_home_path() : wp_upload_dir()['basedir'] . '/';
205
206 return wp_normalize_path( untrailingslashit( $base_path ) . $relative_path );
207 }
208
209 /**
210 * Возвращает путь к изображению относительно корня WP
211 *
212 * @return string
213 */
214 public function get_image_relative_path() {
215 return wp_normalize_path( $this->get_file_path() );
216 }
217
218 /**
219 * Возвращает абсолютный путь к изображению
220 *
221 * @return string
222 */
223 public function get_image_absolute_path() {
224 $relative_path = $this->get_image_relative_path();
225 // Use get_home_path() to match how real_path_to_relative() calculates relative paths
226 $base_path = is_main_site() ? get_home_path() : wp_upload_dir()['basedir'] . '/';
227
228 return wp_normalize_path( untrailingslashit( $base_path ) . $relative_path );
229 }
230
231 /**
232 * Возвращает URL изображения
233 *
234 * @return string
235 */
236 public function get_image_url() {
237 $relative_path = $this->get_image_relative_path();
238
239 return home_url( $relative_path );
240 }
241
242 /**
243 * Возвращает WebP размер основного изображения
244 *
245 * @return int
246 */
247 public function get_webp_main_size() {
248 return $this->webp_main_size;
249 }
250
251 /**
252 * Устанавливает WebP размер основного изображения
253 *
254 * @param int $webp_main_size
255 *
256 * @return void
257 */
258 public function set_webp_main_size( $webp_main_size ) {
259 $this->webp_main_size = $webp_main_size;
260 }
261 }
262