@@ -273,6 +273,14 @@ function clwc_wysiwyg_field( $args ) {
273
273
wp_editor ( wp_kses_post ( $ args ['value ' ] ), $ args ['name ' ], [ 'textarea_name ' => esc_attr ( $ args ['name ' ] ) ] );
274
274
}
275
275
276
+ /**
277
+ * Render image upload field.
278
+ *
279
+ * @param array $args Field arguments.
280
+ *
281
+ * @since 2.0.0
282
+ * @return void
283
+ */
276
284
/**
277
285
* Render image upload field.
278
286
*
@@ -282,39 +290,42 @@ function clwc_wysiwyg_field( $args ) {
282
290
* @return void
283
291
*/
284
292
function clwc_image_upload_field ( $ args ) {
285
- $ image_id = intval ( $ args ['value ' ] );
293
+ $ image_id = intval ( $ args ['value ' ] );
286
294
$ image_url = $ image_id ? wp_get_attachment_url ( $ image_id ) : '' ;
287
295
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
+
288
298
// Hidden field to store the image ID.
289
299
printf (
290
300
'<input type="hidden" name="%1$s" value="%2$s" class="clwc-image-id" /> ' ,
291
301
esc_attr ( $ args ['name ' ] ),
292
302
esc_attr ( $ image_id )
293
303
);
294
304
295
- // Image preview (only displayed if an image is set).
305
+ // Image preview (displayed only if an image is set).
296
306
if ( $ image_url ) {
297
307
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" /> ' ,
299
309
esc_url ( $ image_url )
300
310
);
301
311
} 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" /> ' ;
304
313
}
305
314
306
315
// Button to open media uploader.
307
316
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> ' ,
309
318
esc_html__ ( 'Upload Image ' , 'customer-loyalty-for-woocommerce ' )
310
319
);
311
320
312
321
// Button to remove image.
313
322
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> ' ,
315
324
$ image_url ? 'inline-block ' : 'none ' ,
316
325
esc_html__ ( 'Remove Image ' , 'customer-loyalty-for-woocommerce ' )
317
326
);
327
+
328
+ echo '</div> ' ;
318
329
}
319
330
320
331
/**
0 commit comments