我正在建立一个在Magento2平台上的网站。我需要添加出售的艺术家完成的绘画图像。
什么是需要的是,除了图像被上传,我想添加2-3预定义的背景图像到绘画。例如-餐厅,客厅。
我能够改变背景图像在每个页面加载(随机)使用此代码。
<head>
<style type="text/css">
<!--
body{
background: url(images/<?php echo $selectedBg; ?>) no-repeat;
}
-->
</style>
</head>
<?php
$bg = array('SET_A_01_Living.jpg', 'SET_A_02_Bed.jpg', 'SET_A_03_Study.jpg', 'SET_A_04_Dining.jpg' ); // array of filenames
$i = rand(0, count($bg)-1); // generate random number size of the array
$selectedBg = "$bg[$i]"; // set variable equal to which random filename was chosen
?>
但是我如何在图像和Magento Gallery中添加背景,我无法弄清楚。
这方面的一些指导/提示将帮助我实现我正在尝试做的事情。
发布于 2018-01-25 13:51:40
你必须在head标签上面写php,如下所示:-
<?php
$bg = array('SET_A_01_Living.jpg', 'SET_A_02_Bed.jpg', 'SET_A_03_Study.jpg', 'SET_A_04_Dining.jpg' ); // array of filenames
$i = rand(0, count($bg)-1); // generate random number size of the array
$selectedBg = $bg[$i]; // set variable equal to which random filename was chosen
?>
<head>
<style type="text/css">
<!--
body{
background: url(images/<?php echo $selectedBg; ?>) no-repeat;
}
-->
</style>
</head>
https://stackoverflow.com/questions/48433492
复制相似问题