Category: Amazing Temples English

esc_html__( 'Bild wählen', 'at-sidebar' ), 'select' => esc_html__( 'Auswählen', 'at-sidebar' ), 'remove' => esc_html__( 'Entfernen', 'at-sidebar' ), ] ); wp_add_inline_script( $js_handle, "(function($){$(function(){ function bind(container){ container.on('click','.at-term-image-upload',function(e){ e.preventDefault(); var wrap = $(this).closest('.form-field, tr'); var idField = wrap.find('.at-term-image-id'); var preview = wrap.find('.at-term-image-preview'); var removeBtn = wrap.find('.at-term-image-remove'); var frame = wp.media({ title: ATTermImgL10n.chooseImage, button:{ text: ATTermImgL10n.select }, multiple:false }); frame.on('select', function(){ var att = frame.state().get('selection').first().toJSON(); idField.val(att.id); var url = (att.sizes && att.sizes.medium) ? att.sizes.medium.url : att.url; preview.attr('src', url).show(); removeBtn.show(); }); frame.open(); }); container.on('click','.at-term-image-remove',function(e){ e.preventDefault(); var wrap = $(this).closest('.form-field, tr'); wrap.find('.at-term-image-id').val(''); wrap.find('.at-term-image-preview').hide().attr('src',''); $(this).hide(); }); } bind($(document.body)); });})(jQuery);" ); }); /** * Feld im "Neu hinzufügen" Formular */ add_action( 'category_add_form_fields', function() { $meta_key = 'at_term_image_id'; ?>

term_id, $meta_key, true ); $url = $id ? wp_get_attachment_image_url( $id, 'medium' ) : ''; $style = $url ? '' : 'display:none;'; ?>

$v ) { $new[ $k ] = $v; if ( $k === 'name' ) { $new['at_term_image'] = esc_html__( 'Bild', 'at-sidebar' ); } } return $new; } ); add_filter( 'manage_category_custom_column', function( $out, $col, $term_id ) { if ( $col !== 'at_term_image' ) { return $out; } $id = (int) get_term_meta( $term_id, 'at_term_image_id', true ); $url = $id ? wp_get_attachment_image_url( $id, 'thumbnail' ) : ''; if ( $url ) { $out = ''; } else { $out = '—'; // Gedankenstrich, HTML-escaped } return $out; }, 10, 3 );