Skip to content

Commit 528cefa

Browse files
committed
👌 IMPROVE: Updated admin settings
1 parent 0a4c316 commit 528cefa

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

admin/clwc-admin-settings.php

+18-7
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,14 @@ function clwc_wysiwyg_field( $args ) {
273273
wp_editor( wp_kses_post( $args['value'] ), $args['name'], [ 'textarea_name' => esc_attr( $args['name'] ) ] );
274274
}
275275

276+
/**
277+
* Render image upload field.
278+
*
279+
* @param array $args Field arguments.
280+
*
281+
* @since 2.0.0
282+
* @return void
283+
*/
276284
/**
277285
* Render image upload field.
278286
*
@@ -282,39 +290,42 @@ function clwc_wysiwyg_field( $args ) {
282290
* @return void
283291
*/
284292
function clwc_image_upload_field( $args ) {
285-
$image_id = intval( $args['value'] );
293+
$image_id = intval( $args['value'] );
286294
$image_url = $image_id ? wp_get_attachment_url( $image_id ) : '';
287295

296+
echo '<div class="clwc-image-upload-wrapper" style="display: flex; flex-direction: column; align-items: center; background: #fff; padding: 15px; border: 1px solid #ddd; border-radius: 5px; max-width: 200px;">';
297+
288298
// Hidden field to store the image ID.
289299
printf(
290300
'<input type="hidden" name="%1$s" value="%2$s" class="clwc-image-id" />',
291301
esc_attr( $args['name'] ),
292302
esc_attr( $image_id )
293303
);
294304

295-
// Image preview (only displayed if an image is set).
305+
// Image preview (displayed only if an image is set).
296306
if ( $image_url ) {
297307
printf(
298-
'<img src="%s" style="max-width:150px;display:block;margin-top:10px;" class="clwc-image-preview" />',
308+
'<img src="%s" style="max-width:150px; margin-bottom: 10px;" class="clwc-image-preview" />',
299309
esc_url( $image_url )
300310
);
301311
} else {
302-
// Placeholder (or hidden image preview if no image is set).
303-
echo '<img src="" style="max-width:150px;display:none;margin-top:10px;" class="clwc-image-preview" />';
312+
echo '<img src="" style="max-width:150px; display:none; margin-bottom: 10px;" class="clwc-image-preview" />';
304313
}
305314

306315
// Button to open media uploader.
307316
printf(
308-
'<button type="button" class="button clwc-upload-image-button">%s</button>',
317+
'<button type="button" class="button clwc-upload-image-button" style="margin: 5px 0;">%s</button>',
309318
esc_html__( 'Upload Image', 'customer-loyalty-for-woocommerce' )
310319
);
311320

312321
// Button to remove image.
313322
printf(
314-
'<button type="button" class="button clwc-remove-image-button" style="display:%s;">%s</button>',
323+
'<button type="button" class="button clwc-remove-image-button" style="display:%s; margin: 5px 0;">%s</button>',
315324
$image_url ? 'inline-block' : 'none',
316325
esc_html__( 'Remove Image', 'customer-loyalty-for-woocommerce' )
317326
);
327+
328+
echo '</div>';
318329
}
319330

320331
/**

0 commit comments

Comments
 (0)