• Resolved komputereka

    (@komputereka)


    I want to create multiple background with radio-image.
    I was trying this code to call but it doesn’t work:

    if ( ot_get_option(body_background') != '' ) {
    	$styles .= '.body{ background: '.ot_get_option('body_background').'; }'."\n";
    }

    My question is “the code” to call by value when I select each background.
    Sorry for my ignorance. I hope u can answare my question because it was 3 days since I post this thread.

    The function code I put in function.php :

    function filter_radio_images( $array, $field_id ) {
      if ( $field_id == 'body_background' ) {
        $array = array(
    	array(
    		'value'		=> '1',
    		'label'		=> '1',
    		'src'		=> get_template_directory_uri() . '/functions/images/pattern/pattern-1.png'
    	),
    	array(
    		'value'		=> '2',
    		'label'		=> '2',
    		'src'		=> get_template_directory_uri() . '/functions/images/pattern/pattern-2.png'
    	),
    	array(
    		'value'		=> '3',
    		'label'		=> '3',
    		'src'		=> get_template_directory_uri() . '/functions/images/pattern/pattern-3.png'
    	)
        );
      }
    
      return $array;
    
    }

    And code in demo-theme-options.php :

    array(
    	'id'		=> 'color-header-menu100',
    	'label'		=> 'Header Menu Background 100%',
    	'std'		=> ' ',
    	'type'		=> 'radio-image',
    	'section'	=> 'styling',
    	'class'		=> '',
    	'choices'	=> array(),
    	'settings'	=> array(
    		array(
    			'value'		=> '1',
    			'label'		=> 'bg1',
    			'src'		=> get_template_directory_uri() . '/functions/images/pattern/pattern-1.png',
    			'choices'	=> array(),
    		),
    		array(
    			'value'		=> '2',
    			'label'		=> 'bg2',
    			'src'		=> get_template_directory_uri() . '/functions/images/pattern/pattern-2.png',
    			'choices'	=> array(),
    		),
    		array(
    		'value'		=> '3',
    		'label'		=> 'bg3',
    		'src'		=> get_template_directory_uri() . '/functions/images/pattern/pattern-3.png'
    		)
    	  )
    	),

    https://www.ads-software.com/support/plugin/option-tree

    https://www.ads-software.com/plugins/option-tree/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Derek Herman

    (@valendesigns)

    You’re trying to add the choices via the settings array in your demo-theme-options.php. Also, how are you filtering the radio images with the filter_radio_images function, which hook is it being called from?

    Thread Starter komputereka

    (@komputereka)

    Chayo!!!!!!

    Many fault in my code, but finally I success. Thanks Derek.

    if ( ot_get_option('body_background') == '1' ) {
    $styles .= '.color-header-menu100 { background: url('.get_template_directory_uri().'/functions/images/pattern/pattern-1.png) repeat; }'."\n"; }

    * my id different between function.php and theme-option.php
    * now without filter_radio_images in function.php, just in theme-option.php
    * I must go to googletranslate to change my native language when post here. xixixi

    if ( ot_get_option('id_here') == 'value_here' ) {
    $styles .= 'class/id_here { background: url(image_url_here) repeat; }'."\n"; }
    Plugin Author Derek Herman

    (@valendesigns)

    Glad it’s all sorted. Cheers!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Radio Image’ is closed to new replies.