Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add image size on image field #1529

Closed
ravishakya opened this issue Sep 12, 2017 · 3 comments
Closed

Add image size on image field #1529

ravishakya opened this issue Sep 12, 2017 · 3 comments

Comments

@ravishakya
Copy link

Feature Request

Currently if we want to get the custom image size we have to get the id from the url and then again get the size. By adding size in the image field it will be more efficient.

Kirki::add_field( 'my_config', array(
	'type'        => 'image',
        'size'         => 'thumbnail' // Add new parameter to get custom size image
	'settings'    => 'image_demo',
	'label'       => __( 'This is the label', 'my_textdomain' ),
	'section'     => 'my_section'
) )
@aristath
Copy link
Contributor

Actually there already is a way... try adding this:

'choices' => array(
    'save_as' => 'array',
),

This will save the value as an array containing the URL, ID, width, height.

@ravishakya
Copy link
Author

I have used that and got error.

Error Message

Error Image

My code

Kirki::add_field( 'cyclone_blog', array(
	'type'        => 'image',
	'settings'    => 'banner_image',
	'label'       => esc_html__( 'Select Banner Image', 'cyclone-blog' ),
	'section'     => 'homepage',
	'active_callback'    => array(
		array(
			'setting'  => 'slider_banner',
			'operator' => '==',
			'value'    => 'banner',
		),
	),
	'choices' => array(
	    'save_as' => 'array',
	),	
) );

@aristath
Copy link
Contributor

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants