acf_field_gallery::render_field_settings()publicACF 3.6

Create extra options for your field. This is rendered when editing a field. The value of $field['name'] can be used (like bellow) to save extra data to the $field

@type action

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

Хуков нет.

Возвращает

null. Ничего.

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

$acf_field_gallery = new acf_field_gallery();
$acf_field_gallery->render_field_settings( $field );
$field (обязательный)
-

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

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

Код acf_field_gallery::render_field_settings() ACF 5.10.2

function render_field_settings( $field ) {

	// clear numeric settings
	$clear = array(
		'min',
		'max',
		'min_width',
		'min_height',
		'min_size',
		'max_width',
		'max_height',
		'max_size',
	);

	foreach ( $clear as $k ) {

		if ( empty( $field[ $k ] ) ) {
			$field[ $k ] = '';
		}
	}

	// return_format
	acf_render_field_setting(
		$field,
		array(
			'label'        => __( 'Return Format', 'acf' ),
			'instructions' => '',
			'type'         => 'radio',
			'name'         => 'return_format',
			'layout'       => 'horizontal',
			'choices'      => array(
				'array' => __( 'Image Array', 'acf' ),
				'url'   => __( 'Image URL', 'acf' ),
				'id'    => __( 'Image ID', 'acf' ),
			),
		)
	);

	// preview_size
	acf_render_field_setting(
		$field,
		array(
			'label'        => __( 'Preview Size', 'acf' ),
			'instructions' => '',
			'type'         => 'select',
			'name'         => 'preview_size',
			'choices'      => acf_get_image_sizes(),
		)
	);

	// insert
	acf_render_field_setting(
		$field,
		array(
			'label'        => __( 'Insert', 'acf' ),
			'instructions' => __( 'Specify where new attachments are added', 'acf' ),
			'type'         => 'select',
			'name'         => 'insert',
			'choices'      => array(
				'append'  => __( 'Append to the end', 'acf' ),
				'prepend' => __( 'Prepend to the beginning', 'acf' ),
			),
		)
	);

	// library
	acf_render_field_setting(
		$field,
		array(
			'label'        => __( 'Library', 'acf' ),
			'instructions' => __( 'Limit the media library choice', 'acf' ),
			'type'         => 'radio',
			'name'         => 'library',
			'layout'       => 'horizontal',
			'choices'      => array(
				'all'        => __( 'All', 'acf' ),
				'uploadedTo' => __( 'Uploaded to post', 'acf' ),
			),
		)
	);

	// min
	acf_render_field_setting(
		$field,
		array(
			'label'        => __( 'Minimum Selection', 'acf' ),
			'instructions' => '',
			'type'         => 'number',
			'name'         => 'min',
		)
	);

	// max
	acf_render_field_setting(
		$field,
		array(
			'label'        => __( 'Maximum Selection', 'acf' ),
			'instructions' => '',
			'type'         => 'number',
			'name'         => 'max',
		)
	);

	// min
	acf_render_field_setting(
		$field,
		array(
			'label'        => __( 'Minimum', 'acf' ),
			'instructions' => __( 'Restrict which images can be uploaded', 'acf' ),
			'type'         => 'text',
			'name'         => 'min_width',
			'prepend'      => __( 'Width', 'acf' ),
			'append'       => 'px',
		)
	);

	acf_render_field_setting(
		$field,
		array(
			'label'   => '',
			'type'    => 'text',
			'name'    => 'min_height',
			'prepend' => __( 'Height', 'acf' ),
			'append'  => 'px',
			'_append' => 'min_width',
		)
	);

	acf_render_field_setting(
		$field,
		array(
			'label'   => '',
			'type'    => 'text',
			'name'    => 'min_size',
			'prepend' => __( 'File size', 'acf' ),
			'append'  => 'MB',
			'_append' => 'min_width',
		)
	);

	// max
	acf_render_field_setting(
		$field,
		array(
			'label'        => __( 'Maximum', 'acf' ),
			'instructions' => __( 'Restrict which images can be uploaded', 'acf' ),
			'type'         => 'text',
			'name'         => 'max_width',
			'prepend'      => __( 'Width', 'acf' ),
			'append'       => 'px',
		)
	);

	acf_render_field_setting(
		$field,
		array(
			'label'   => '',
			'type'    => 'text',
			'name'    => 'max_height',
			'prepend' => __( 'Height', 'acf' ),
			'append'  => 'px',
			'_append' => 'max_width',
		)
	);

	acf_render_field_setting(
		$field,
		array(
			'label'   => '',
			'type'    => 'text',
			'name'    => 'max_size',
			'prepend' => __( 'File size', 'acf' ),
			'append'  => 'MB',
			'_append' => 'max_width',
		)
	);

	// allowed type
	acf_render_field_setting(
		$field,
		array(
			'label'        => __( 'Allowed file types', 'acf' ),
			'instructions' => __( 'Comma separated list. Leave blank for all types', 'acf' ),
			'type'         => 'text',
			'name'         => 'mime_types',
		)
	);
}