ACF-Image-Select icon indicating copy to clipboard operation
ACF-Image-Select copied to clipboard

Please add formatting options

Open Pondake opened this issue 5 years ago • 1 comments

Please add this:

acf_render_field_setting( $field, array(
	'label'			=> __('Return Format','acf'),
	'instructions'	=> '',
	'type'			=> 'radio',
	'name'			=> 'return_format',
	'choices'		=> array(
		'url'		=> __("URL",'acf'),
		'val'			=> __("Choice value",'acf'),
	),
	'layout'	=>	'horizontal',
));

Below "acf render field setting, image extension". And:

$this->name        = 'image_select';
	$this->label       = __('Image Select');
	$this->category    = __("Choice",'acf');
	$this->defaults    = array(
		'choices'			=>	array(),
		'default_value'		=>	'',
		'multiple'          => 0,
		'return_format'			=> 'url',
		'image_path'		=>	get_template_directory_uri() . '/images/',
		'image_extension'   => 'png',
);

To support it with a default value.

And:

if( $field['return_format'] == 'url' ) {
	$retvalue = $field['image_path'] . esc_attr($value) . '.'.$field['image_extension'];
} else {
	$retvalue = esc_attr($value);
}

Within format value, replacing

$retvalue = $field['image_path'] . esc_attr($value) . '.'.$field['image_extension'];

Pondake avatar Mar 20 '19 10:03 Pondake

thank you for this guide! @Pondake

alexanderdejong avatar Jun 24 '19 08:06 alexanderdejong