Page 1 of 1

[bgstretcher] javascript while loading template

Posted: Wed Jun 29, 2011 7:08 am
by vinyl
I want to use the jquery script "bgstretcher". What that does is stretch a background image you supply to whatever size your window is.

I have it working correctly but I would like someone to be able to choose it within CMSMS.

The way you set it is by adding the path to an image within the javascript.

Code: Select all

$(document).ready(function(){
        //  Initialize Backgound Stretcher	   
		$(document).bgStretcher({
			images: ['uploads/site/images/image.jpg'],
			imageWidth: 800, imageHeight: 600
		});
The script is placed in the "Page Specific Metadata" field of my page.

Is there anyway to include a variable in there or maybe load this with the gallery and pass a variable so you are able to choose an image?

I could make a gallery with only one image that is active, so that solves the choosing, but how can I pass that in the javascript that is loaded with my page?

Any ideas?

Re: [bgstretcher] javascript while loading template

Posted: Wed Jun 29, 2011 9:03 am
by uniqu3
You could use {content_image} tag for image selection, or if you want to be able to see image thumb look at GBFilePicker module.

So in your js code you could do following:

Code: Select all

{literal}
$(document).ready(function(){
        //  Initialize Backgound Stretcher      
      $(document).bgStretcher({
         images: ['{/literal}{content_image block='bg_image' dir='yourpath'}{literal}'],
         imageWidth: 800, imageHeight: 600
      });
{/literal}

Re: [bgstretcher] javascript while loading template

Posted: Wed Jun 29, 2011 3:11 pm
by vinyl
Ah ok, I could use that! Thanks, will check it out tonight.