Question about adding image attribute in combination with js

Permalink
I want to change the image url to a attribute image. Please help me with the right code for it.
I tried
<?php $img = $c->getAttribute('headerimg'.$i); ?>
("headerimg" is the attribute name)

<!-- PAGE TITLE BACKGROUND IMAGE -->
    <script type="text/javascript">
       <script type="text/javascript">
        jQuery(document).ready(function () {
            "use strict";
           jQuery('#page-title-container').backstretch("images/photos/1800x1000.gif", {
                fade: 500
            });
        });
    </script>

 
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi powerarea,

You can try this:
<script>
jQuery(document).ready(function () {
    "use strict";
    jQuery('#page-title-container').backstretch("<?php if (is_object($c->getAttribute('headerimg'))) { echo $c->getAttribute('headerimg')->getRelativePath(); } ?>", {
        fade: 500
    });
});
</script>
powerarea replied on at Permalink Reply
Thanks! It works great!