WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Авторские Темы для WordPress
функция не описана

acf_field_gallery::render_attachment() public ACF 5.0.0

Renders the sidebar HTML shown when selecting an attachmemnt.

{} Это метод класса: acf_field_gallery{}

Хуков нет.

Возвращает

null. Ничего.

Использование

$acf_field_gallery = new acf_field_gallery();
$acf_field_gallery->render_attachment( $id, $field );
$id(int)
The attachment ID.
$field(массив) (обязательный)
The field array.

Список изменений

С версии 5.0.0 Введена.

Код acf_field_gallery::render_attachment() ACF 5.9.1

<?php
function render_attachment( $id = 0, $field ) {
	
	// Load attachmenet data.
	$attachment = wp_prepare_attachment_for_js( $id );
	$compat = get_compat_media_markup( $id );
	
	// Get attachment thumbnail (video).
	if( isset($attachment['thumb']['src']) ) {
		$thumb = $attachment['thumb']['src'];
	
	// Look for thumbnail size (image).
	} elseif( isset($attachment['sizes']['thumbnail']['url']) ) {
		$thumb = $attachment['sizes']['thumbnail']['url'];
	
	// Use url for svg.
	} elseif( $attachment['type'] === 'image' ) {
		$thumb = $attachment['url'];
	
	// Default to icon.
	} else {
		$thumb = wp_mime_type_icon( $id );	
	}
	
	// Get attachment dimensions / time / size.
	$dimensions = '';
	if( $attachment['type'] === 'audio' ) {
		$dimensions = __('Length', 'acf') . ': ' . $attachment['fileLength'];	
	} elseif( !empty($attachment['width']) ) {
		$dimensions = $attachment['width'] . ' x ' . $attachment['height'];
	}
	if( !empty($attachment['filesizeHumanReadable']) ) {
		$dimensions .=  ' (' . $attachment['filesizeHumanReadable'] . ')';
	}
	
	?>
	<div class="acf-gallery-side-info">
		<img src="<?php echo esc_attr($thumb); ?>" alt="<?php echo esc_attr($attachment['alt']); ?>" />
		<p class="filename"><strong><?php echo esc_html($attachment['filename']); ?></strong></p>
		<p class="uploaded"><?php echo esc_html($attachment['dateFormatted']); ?></p>
		<p class="dimensions"><?php echo esc_html($dimensions); ?></p>
		<p class="actions">
			<a href="#" class="acf-gallery-edit" data-id="<?php echo esc_attr($id); ?>"><?php _e('Edit', 'acf'); ?></a>
			<a href="#" class="acf-gallery-remove" data-id="<?php echo esc_attr($id); ?>"><?php _e('Remove', 'acf'); ?></a>
		</p>
	</div>
	<table class="form-table">
		<tbody>
			<?php 
			
			// Render fields.
			$prefix = 'attachments[' . $id . ']';
			
			acf_render_field_wrap(array(
				//'key'		=> "{$field['key']}-title",
				'name'		=> 'title',
				'prefix'	=> $prefix,
				'type'		=> 'text',
				'label'		=> __('Title', 'acf'),
				'value'		=> $attachment['title']
			), 'tr');
			
			acf_render_field_wrap(array(
				//'key'		=> "{$field['key']}-caption",
				'name'		=> 'caption',
				'prefix'	=> $prefix,
				'type'		=> 'textarea',
				'label'		=> __('Caption', 'acf'),
				'value'		=> $attachment['caption']
			), 'tr');
			
			acf_render_field_wrap(array(
				//'key'		=> "{$field['key']}-alt",
				'name'		=> 'alt',
				'prefix'	=> $prefix,
				'type'		=> 'text',
				'label'		=> __('Alt Text', 'acf'),
				'value'		=> $attachment['alt']
			), 'tr');
			
			acf_render_field_wrap(array(
				//'key'		=> "{$field['key']}-description",
				'name'		=> 'description',
				'prefix'	=> $prefix,
				'type'		=> 'textarea',
				'label'		=> __('Description', 'acf'),
				'value'		=> $attachment['description']
			), 'tr');
			
			?>
		</tbody>
	</table>
	<?php
	
	// Display compat fields.
	echo $compat['item'];
}