1

this displays the image

<img src=\"'.($img).'\" alt=\"\" />

and I want to make it to where I can use it in css for a background image, in order to repeat and the only way I can think of is turning it into a background image in css.

<style>
background-image: ???;
background-repeat: y;
</style>

overall how can I turn this (I believe an associative array) into css?

'.($img).'

Here is the whole code:

function add_logo_css() {
    $img = get_option('add_logo_logo');
    if(!empty($img))
        echo '<style type="text/css">
#admin-logo { margin: 10px 0; padding: 0 0 5px; border-bottom: 1px solid #ddd;  position:absolute; margin-left: 165px; width:100%; }
</style>'."\n";
}

function add_logo_script() {
    $img = get_option('add_logo_logo');
    if(!empty($img))
        echo '<script type="text/javascript">
/* <![CDATA[ */
(function($) {
    $("#wpwrap").prepend("<div id=\"admin-logo\">
<img src=\"'.($img).'\" alt=\"\" /></div>");
})(jQuery);
/* ]]> */
</script>';
}
user1757516
  • 63
  • 1
  • 9

2 Answers2

0

You can use javascript for that:

<img id="myImg" alt="" />
<script language="text/javascript">
    document.getElementById("myImg").style="background-image: url('.($img).'); background-repeat: repeat-y;";
</script>
Majid Laissi
  • 19,188
  • 19
  • 68
  • 105
0

I expect the variable is a PHP string variable, containing an image url, and you are currently in a php block when outputting the style tags. If so, this voodoo should work.

<style>
  background-image: url("'.$img.'");
  background-repeat: repeat-y; /* <~~ corrected */
</style>
Billy Moon
  • 57,113
  • 24
  • 136
  • 237