我想使用redux-framework更改我的背景图片。我使用了以下代码,但它不起作用。首先是我的redux-code,第二个是我的css代码。如果有任何替代方法,请提及。
array(
'name' => "Background parttern",
'id' => "background_parttern",
'std' => "pattern11",
'type' => "image_select",
'title' => __('Homepage Layout', 'personalblog'),
'subtitle' => __('Select Your Background Pattern.', 'personalblog'),
'options' => array(
'pattern1' => $personalblog_admin_img_dir . 'patterns/pattern1.png',
'pattern2' => $personalblog_admin_img_dir . 'patterns/pattern2.png',
'pattern54' => $personalblog_admin_img_dir . 'patterns/pattern54.png'
),
'output' => array('background-image' => 'body' ),
),
CSS代码:
body {
font-family: 'Noto Serif', serif;
font-size: 14px;
background-image: url('image/patterns/pattern2.png');
background-repeat: repeat;
}
答案 0 :(得分:0)
您可以使用此代码作为参考: -
array( 'name' => "Background parttern", 'id' => "background_parttern", 'std' => "pattern11", 'type' => "select_image", 'title' => __('Homepage Layout', 'personalblog'), 'subtitle' => __('Select Your Background Pattern.', 'personalblog'), 'options' => Array( 'pattern1' => Array ( 'alt' => 'pattern1', 'img' => get_template_directory_uri() . 'image/patterns/pattern1.png',), 'pattern2' => Array ('alt' => 'pattern2', 'img' =>get_template_directory_uri() . 'image/patterns/pattern2.png', ) ), 'output' => array('background-image' => 'body' ), ),
body { font-family: 'Noto Serif', serif; font-size: 14px; background-image: url("<?php echo '' . $redux_Options_name['background_parttern']; ?>"); background-repeat: repeat; }
我希望这会对你有所帮助。