Support

Account

Home Forums Backend Issues (wp-admin) Conditional branch to "Preview Size" on edit screen in diffrent custon post type Reply To: Conditional branch to "Preview Size" on edit screen in diffrent custon post type

  • Dear John Huebner.

    Thank you for your quick reply.

    It works fine as below.

    in functions.php

    function my_acf_modify_img_field($field) {
    	if(get_post_type() === 'Post Type A') {
    		$field['preview_size'] = 'preview_for_A';
    	} elseif(get_post_type() === 'Post Type B') {
    		$field['preview_size'] = 'preview_for_B';
    	}
    	return $field;
    }
    
    add_filter('acf/prepare_field/name=cf_my_img', 'my_acf_modify_img_field');

    I deeply appreciate you.