Support

Account

Home Forums ACF PRO Problems with image field in Option page

Solved

Problems with image field in Option page

  • Hi 🙂
    I created an Option page and the related fields using ACF Pro 5.4.5 plugin.
    That all works and displays correctly and as expected:
    All looks and works as expected

    However once i export the generated php and add it to my child themes function.php file..along with adding the plugin to the child theme folder etc.
    It all works however the first field group on the option page displays a content editor box above the image upload option.
    Includes content editor section??

    Any help with resolving this appreciated

    ok.. trying again.. link to first screenshot1.
    All looks fine as expected
    screenshot1

    and link to screenshot2 where it goes pearshaped but only for the first field group for the image field.
    this happens even if i move the field groups around. whichever one is then first it happens to for the image field

    screenshot2

    Im using WP 4.6.1 ACF Pro 5.4.5
    No plugins installed apart from default Akismet and Hello Dolly
    No themes installed apart from the ones installed with WP by default
    and the twentysixteen child theme i have created in which i have added acf pro

    This is my code in my child theme functions php file

    // Queue parent and child theme style sheets
    function chronwin_theme_enqueue_styles() {
      
      $parent_style = 'parent-style'; 
      
      wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
      wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( $parent_style ), wp_get_theme()->get('Version'));
    }
    add_action( 'wp_enqueue_scripts', 'chronwin_theme_enqueue_styles' );
    
    // Customize ACF path
    add_filter('advanced-custom-fields-pro/settings/path', 'my_acf_settings_path');
     
    function my_acf_settings_path( $path ) {
     
        // update path
        $path = get_stylesheet_directory() . '/advanced-custom-fields-pro/';
        
        // return
        return $path;
        
    }
     
    
    // Customize ACF dir
    add_filter('advanced-custom-fields-pro/settings/dir', 'my_acf_settings_dir');
     
    function my_acf_settings_dir( $dir ) {
     
        // update path
        $dir = get_stylesheet_directory_uri() . '/advanced-custom-fields-pro/';
        
        // return
        return $dir;
        
    }
     
    // Include ACF
    include_once( get_stylesheet_directory() . '/advanced-custom-fields-pro/acf.php' );
    
    //* Add Options page
    if( function_exists('acf_add_options_page') ) {	
    	acf_add_options_page();	
    }
    
    if( function_exists('acf_set_options_page_title') ) {
        acf_set_options_page_title( __('Homepage Main Service Options') );
    }
    
    // Add ACF field groups etc via generated PHP 
    
    if( function_exists('acf_add_local_field_group') ):
    
    acf_add_local_field_group(array (
    	'key' => 'group_57ddf93d8343d',
    	'title' => 'Homepage Left Column Featured Services',
    	'fields' => array (
    		array (
    			'key' => 'field_57ddf9c097c03',
    			'label' => 'Left Featured Section Title',
    			'name' => 'chronwin_left_featured_section_title',
    			'type' => 'text',
    			'instructions' => 'Add the left featured section title',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'placeholder' => 'eg Resume Writing',
    			'prepend' => '',
    			'append' => '',
    			'maxlength' => '',
    		),
    		array (
    			'key' => 'field_57e1e8375df2b',
    			'label' => 'Left Section Image',
    			'name' => 'chronwin_left_section_image',
    			'type' => 'image',
    			'instructions' => 'Upload an the left section image',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'return_format' => 'array',
    			'preview_size' => 'thumbnail',
    			'library' => 'all',
    			'min_width' => '',
    			'min_height' => '',
    			'min_size' => '',
    			'max_width' => '',
    			'max_height' => '',
    			'max_size' => '',
    			'mime_types' => '',
    		),
    		array (
    			'key' => 'field_57ddfaaf97c05',
    			'label' => 'Left Featured Section Link',
    			'name' => 'chronwin_left_featured_section_link',
    			'type' => 'url',
    			'instructions' => 'Add url of page being linked to eg http://www.google.com',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'placeholder' => 'eg http://www.domain.com/contact/',
    		),
    		array (
    			'key' => 'field_57ddfb7497c06',
    			'label' => 'Left Featured Section Button Text',
    			'name' => 'chronwin_left_featured_section_button_text',
    			'type' => 'text',
    			'instructions' => 'Add the button text',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'placeholder' => 'eg Click Me!',
    			'prepend' => '',
    			'append' => '',
    			'maxlength' => '',
    		),
    	),
    	'location' => array (
    		array (
    			array (
    				'param' => 'options_page',
    				'operator' => '==',
    				'value' => 'acf-options',
    			),
    		),
    	),
    	'menu_order' => 0,
    	'position' => 'normal',
    	'style' => 'default',
    	'label_placement' => 'top',
    	'instruction_placement' => 'label',
    	'hide_on_screen' => '',
    	'active' => 1,
    	'description' => '',
    ));
    
    acf_add_local_field_group(array (
    	'key' => 'group_57ddfcd3e7faf',
    	'title' => 'Homepage Middle Column Featured Services',
    	'fields' => array (
    		array (
    			'key' => 'field_57ddfcd418768',
    			'label' => 'Middle Featured Section Title',
    			'name' => 'chronwin_middle_featured_section_title',
    			'type' => 'text',
    			'instructions' => 'Add the middle featured section title',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'placeholder' => 'eg Resume Writing',
    			'prepend' => '',
    			'append' => '',
    			'maxlength' => '',
    		),
    		array (
    			'key' => 'field_57ddfcd418b50',
    			'label' => 'Middle Featured Section Image',
    			'name' => 'chronwin_middle_featured_section_image',
    			'type' => 'image',
    			'instructions' => 'Upload the image for the middle featured section',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'return_format' => 'array',
    			'preview_size' => 'thumbnail',
    			'library' => 'all',
    			'min_width' => '',
    			'min_height' => '',
    			'min_size' => '',
    			'max_width' => '',
    			'max_height' => '',
    			'max_size' => '',
    			'mime_types' => '',
    		),
    		array (
    			'key' => 'field_57ddfcd418f38',
    			'label' => 'Middle Featured Section Link',
    			'name' => 'chronwin_middle_featured_section_link',
    			'type' => 'url',
    			'instructions' => 'Add url of page being linked to eg http://www.google.com',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'placeholder' => 'eg http://www.domain.com/contact/',
    		),
    		array (
    			'key' => 'field_57ddfcd419320',
    			'label' => 'Middle Featured Section Button Text',
    			'name' => 'chronwin_middle_featured_section_button_text',
    			'type' => 'text',
    			'instructions' => 'Add the button text',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'placeholder' => 'eg Click Me!',
    			'prepend' => '',
    			'append' => '',
    			'maxlength' => '',
    		),
    	),
    	'location' => array (
    		array (
    			array (
    				'param' => 'options_page',
    				'operator' => '==',
    				'value' => 'acf-options',
    			),
    		),
    	),
    	'menu_order' => 0,
    	'position' => 'normal',
    	'style' => 'default',
    	'label_placement' => 'top',
    	'instruction_placement' => 'label',
    	'hide_on_screen' => '',
    	'active' => 1,
    	'description' => '',
    ));
    
    acf_add_local_field_group(array (
    	'key' => 'group_57de8b8e0d169',
    	'title' => 'Homepage Right Column Featured Services',
    	'fields' => array (
    		array (
    			'key' => 'field_57de8b8e355fb',
    			'label' => 'Right Featured Section Title',
    			'name' => 'chronwin_right_featured_section_title',
    			'type' => 'text',
    			'instructions' => 'Add the right featured section title',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'placeholder' => 'eg Resume Writing',
    			'prepend' => '',
    			'append' => '',
    			'maxlength' => '',
    		),
    		array (
    			'key' => 'field_57de8b8e359e3',
    			'label' => 'Right Featured Section Image',
    			'name' => 'chronwin_right_featured_section_image',
    			'type' => 'image',
    			'instructions' => 'Upload the image for the right featured section',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'return_format' => 'array',
    			'preview_size' => 'thumbnail',
    			'library' => 'all',
    			'min_width' => '',
    			'min_height' => '',
    			'min_size' => '',
    			'max_width' => '',
    			'max_height' => '',
    			'max_size' => '',
    			'mime_types' => '',
    		),
    		array (
    			'key' => 'field_57de8b8e35dcb',
    			'label' => 'Right Featured Section Link',
    			'name' => 'chronwin_right_featured_section_link',
    			'type' => 'url',
    			'instructions' => 'Add url of page being linked to eg http://www.domain.com',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'placeholder' => 'eg http://www.domain.com/contact/',
    		),
    		array (
    			'key' => 'field_57de8b8e361b3',
    			'label' => 'Right Featured Section Button Text',
    			'name' => 'chronwin_right_featured_section_button_text',
    			'type' => 'text',
    			'instructions' => 'Add the button text',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'placeholder' => 'eg Click Me!',
    			'prepend' => '',
    			'append' => '',
    			'maxlength' => '',
    		),
    	),
    	'location' => array (
    		array (
    			array (
    				'param' => 'options_page',
    				'operator' => '==',
    				'value' => 'acf-options',
    			),
    		),
    	),
    	'menu_order' => 0,
    	'position' => 'normal',
    	'style' => 'default',
    	'label_placement' => 'top',
    	'instruction_placement' => 'label',
    	'hide_on_screen' => '',
    	'active' => 1,
    	'description' => '',
    ));
    
    endif;
  • This reply has been marked as private.
  • Hi @chronwin

    It seems the style and script files are not loaded on the backend. Please keep in mind that the correct hooks are acf/settings/path and acf/settings/dir. So, your code should be like this:

    add_filter('acf/settings/path', 'my_acf_settings_path');

    And:

    add_filter('acf/settings/dir', 'my_acf_settings_dir');

    I hope this helps 🙂

  • That fixed it. thank you 🙂

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Problems with image field in Option page’ is closed to new replies.