Skip to content

Commit fc16c00

Browse files
committed
Clean up the class crops methods
1 parent 5811da2 commit fc16c00

1 file changed

Lines changed: 22 additions & 55 deletions

File tree

php/ui/component/class-crops.php

Lines changed: 22 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ protected function info_box( $struct ) {
9696
* @return array
9797
*/
9898
protected function input( $struct ) {
99-
10099
$mode = $this->setting->get_param( 'mode', 'demos' );
101100
$wrapper = $this->get_part( 'div' );
102101
$wrapper['attributes']['class'][] = 'cld-size-items';
@@ -116,6 +115,28 @@ protected function input( $struct ) {
116115
$size_selector = $this->make_size_selector( $sizes );
117116
$wrapper['children']['size-selector'] = $size_selector;
118117

118+
// Get demo files.
119+
$mode = $this->setting->get_param( 'mode', 'demos' );
120+
121+
/**
122+
* Filter the demo files.
123+
*
124+
* @hook cloudinary_registered_sizes
125+
* @since 3.1.3
126+
*
127+
* @param $demo_files {array} array of demo files.
128+
*
129+
* @return {array}
130+
*/
131+
$examples = apply_filters( 'cloudinary_demo_crop_files', $this->demo_files );
132+
133+
if ( 'full' === $mode ) {
134+
$public_id = $this->setting->get_root_setting()->get_param( 'preview_id' );
135+
if ( ! empty( $public_id ) ) {
136+
$examples = array( $public_id );
137+
}
138+
}
139+
119140
// Create content area for each size.
120141
foreach ( $sizes as $size => $details ) {
121142
if ( empty( $details['crop'] ) ) {
@@ -136,16 +157,6 @@ protected function input( $struct ) {
136157
}
137158
$size_dimensions = implode( ',', $size_array );
138159

139-
// Get demo files.
140-
$mode = $this->setting->get_param( 'mode', 'demos' );
141-
$examples = apply_filters( 'cloudinary_demo_crop_files', $this->demo_files );
142-
if ( 'full' === $mode ) {
143-
$public_id = $this->setting->get_root_setting()->get_param( 'preview_id' );
144-
if ( ! empty( $public_id ) ) {
145-
$examples = array( $public_id );
146-
}
147-
}
148-
149160
// Create image previews container.
150161
$images_container = $this->get_part( 'div' );
151162
$images_container['attributes']['class'][] = 'cld-size-images';
@@ -229,50 +240,6 @@ protected function make_size_selector( $sizes ) {
229240
return $selector;
230241
}
231242

232-
/**
233-
* Make an image selector.
234-
*/
235-
protected function make_selector() {
236-
$selector = $this->get_part( 'div' );
237-
$selector['attributes']['class'][] = 'cld-image-selector';
238-
$mode = $this->setting->get_param( 'mode', 'demos' );
239-
240-
/**
241-
* Filter the demo files.
242-
*
243-
* @hook cloudinary_registered_sizes
244-
* @since 3.1.3
245-
*
246-
* @param $demo_files {array} array of demo files.
247-
*
248-
* @return {array}
249-
*/
250-
$examples = apply_filters( 'cloudinary_demo_crop_files', $this->demo_files );
251-
if ( 'full' === $mode ) {
252-
$public_id = $this->setting->get_root_setting()->get_param( 'preview_id' );
253-
if ( ! empty( $public_id ) ) {
254-
$examples = array(
255-
$public_id,
256-
);
257-
}
258-
}
259-
foreach ( $examples as $index => $file ) {
260-
$name = pathinfo( $file, PATHINFO_FILENAME );
261-
$item = $this->get_part( 'span' );
262-
$item['attributes']['data-image'] = $file;
263-
if ( 0 === $index ) {
264-
$item['attributes']['data-selected'] = true;
265-
266-
}
267-
$item['attributes']['class'][] = 'cld-image-selector-item';
268-
269-
$item['content'] = $name;
270-
$selector['children'][ 'image-' . $index ] = $item;
271-
}
272-
273-
return $selector;
274-
}
275-
276243
/**
277244
* Make an input line.
278245
*

0 commit comments

Comments
 (0)