ExifData.php
3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
namespace AC\Settings\Column;
use AC\Settings;
use AC\View;
class ExifData extends Settings\Column
implements Settings\FormatValue {
const NAME = 'exif_data';
/**
* @var string
*/
private $exif_datatype;
protected function set_name() {
$this->name = self::NAME;
}
protected function define_options() {
return [ 'exif_datatype' => 'aperture' ];
}
public function create_view() {
$setting = $this->create_element( 'select' )
->set_attribute( 'data-label', 'update' )
->set_attribute( 'data-refresh', 'column' )
->set_options( $this->get_exif_types() );
return new View( [
'label' => $this->column->get_label(),
'setting' => $setting,
] );
}
public function get_dependent_settings() {
switch ( $this->get_exif_datatype() ) {
case 'aperture' :
$settings = [ new Settings\Column\BeforeAfter\Aperture( $this->column ) ];
break;
case 'focal_length' :
$settings = [ new Settings\Column\BeforeAfter\FocalLength( $this->column ) ];
break;
case 'iso' :
$settings = [ new Settings\Column\BeforeAfter\ISO( $this->column ) ];
break;
case 'shutter_speed' :
$settings = [ new Settings\Column\BeforeAfter\ShutterSpeed( $this->column ) ];
break;
default :
$settings = [ new Settings\Column\BeforeAfter( $this->column ) ];
}
return $settings;
}
/**
* Get EXIF data
* Get extended image metadata
* @return array EXIF data types
* @since 2.0
*/
private function get_exif_types() {
$exif_types = [
'aperture' => __( 'Aperture', 'codepress-admin-columns' ),
'credit' => __( 'Credit', 'codepress-admin-columns' ),
'camera' => __( 'Camera', 'codepress-admin-columns' ),
'caption' => __( 'Caption', 'codepress-admin-columns' ),
'created_timestamp' => __( 'Timestamp', 'codepress-admin-columns' ),
'copyright' => __( 'Copyright', 'codepress-admin-columns' ),
'focal_length' => __( 'Focal Length', 'codepress-admin-columns' ),
'iso' => __( 'ISO', 'codepress-admin-columns' ),
'shutter_speed' => __( 'Shutter Speed', 'codepress-admin-columns' ),
'title' => __( 'Title', 'codepress-admin-columns' ),
'orientation' => __( 'Orientation', 'codepress-admin-columns' ),
'keywords' => __( 'Keywords', 'codepress-admin-columns' ),
];
natcasesort( $exif_types );
return $exif_types;
}
/**
* @return string
*/
public function get_exif_datatype() {
return $this->exif_datatype;
}
/**
* @param string $exif_datatype
*
* @return bool
*/
public function set_exif_datatype( $exif_datatype ) {
$this->exif_datatype = $exif_datatype;
return true;
}
public function format( $value, $original_value ) {
$exif_datatype = $this->get_exif_datatype();
$value = isset( $value[ $exif_datatype ] ) ? $value[ $exif_datatype ] : '';
if ( false != $value ) {
switch ( $exif_datatype ) {
case 'created_timestamp' :
$value = ac_format_date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $value );
break;
case 'keywords' :
$value = ac_helper()->array->implode_recursive( ', ', $value );
break;
}
}
return $value;
}
}