acf_field_image::render_field_validation_settings()publicACF 6.0

Renders the field settings used in the "Validation" tab.

Метод класса: acf_field_image{}

Хуков нет.

Возвращает

null. Ничего.

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

$acf_field_image = new acf_field_image();
$acf_field_image->render_field_validation_settings( $field );
$field(массив) (обязательный)
The field settings array.

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

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

Код acf_field_image::render_field_validation_settings() ACF 6.0.4

function render_field_validation_settings( $field ) {
	// Clear numeric settings.
	$clear = array(
		'min_width',
		'min_height',
		'min_size',
		'max_width',
		'max_height',
		'max_size',
	);

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

	acf_render_field_setting(
		$field,
		array(
			'label'   => __( 'Minimum', 'acf' ),
			'hint'    => __( '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',
		)
	);

	acf_render_field_setting(
		$field,
		array(
			'label'   => __( 'Maximum', 'acf' ),
			'hint'    => __( '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',
		)
	);

	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',
		)
	);
}