Page 1 of 1

How to get location of image used in Global Content Block

Posted: Thu Jan 05, 2012 10:59 pm
by jpage101
Hello,

I have a few global content blocks that are to be used in an image carousel. I have named them "Rotating-Image-1" "Rotating-Image-2" etc.

My problem is the file location needs to be entered in the template in a few places. The global content block contains the image but the entire global content block would look something like:

Code: Select all

<img src="/uploads/images/xxx.jpg" border="0" class="abc">
Is it possible to get just the source location of the image so I can insert it in several locations on the template that require the location? With the above example the result I am looking for would be:

Code: Select all

/uploads/images/xxx.jpg
Thank you in advance!

Re: How to get location of image used in Global Content Bloc

Posted: Thu Jan 05, 2012 11:53 pm
by Wishbone
It can be done by putting one file per line in the GCB. In the template, you can split on newline and foreach over them.

For me, it's easier to use Gallery for image scrollers.. Create a new Gallery template, and ditch the standard CSS and javascript. Replace the CSS with any styles pertinent to your scroller.. Same with the Javascript. Update the smarty side of the template with your logic, and you will be able to mass upload images and drag-and-drop re-order them, instead of uploading one at a time, then entering the filenames as you are trying to do.

PM me if you need any real world examples/template code for either solution.

Re: How to get location of image used in Global Content Bloc

Posted: Fri Jan 06, 2012 3:27 am
by Dr.CSS
Or use Album ;) ...

Re: How to get location of image used in Global Content Bloc

Posted: Fri Jan 06, 2012 5:20 pm
by jpage101
I installed Gallery, but am having some problems with it. I am sure its probably just something I need to troubleshoot and learn how to use properly. While this may be the best solution long term, and I would love to see some examples of this used in an image carousel...I just need to get this functionality up and running now.

Does a function exist to grab the just the image location from the GCB?

Re: How to get location of image used in Global Content Bloc

Posted: Fri Jan 06, 2012 6:03 pm
by Dr.CSS

Re: How to get location of image used in Global Content Bloc

Posted: Fri Jan 06, 2012 7:57 pm
by jpage101
Dr. CSS, sorry, I did not see the reply the first time. It looks like one of the examples is similar to what I need. If I can figure out how to make it change by itself and limit the number of photos being used, it just might work.

Going to give it a shot now.

Re: How to get location of image used in Global Content Bloc

Posted: Fri Jan 06, 2012 9:43 pm
by jpage101
Dr. Css,

Album looks like a powerful module, but I am a bit confused. I was able to open it in its basic form on a test page. In the link you provided there are different examples. How does one use one of these examples? I assumed there would be a js/css download for each one but I don't see anything.

Apparently I am missing something...

Re: How to get location of image used in Global Content Bloc

Posted: Sat Jan 07, 2012 1:06 pm
by applejack
If the rotator is page specific then just use a naming convention based upon the page alias.

If the same images are to be used on a number of different pages then either use a global block where you just enter the image name(s). Then in the template you can decide depending on how you need to use them either as a background image or a full img tag.

Alternatively if a full image tag is used but you also need to use as background images use regex to strip the tag.

Re: How to get location of image used in Global Content Bloc

Posted: Mon Jan 09, 2012 2:35 pm
by jpage101
hi applejack,

I appreciate the feedback, but i don't think this is what I need. The end users need to be able to upload the photos with ease. Entering an image name in a GCB is not an option for them.

Basically, on the entire site (each page) there is a div with a horizontal list of 5 small images below it. The div should display/auto rotate each image. Also allow the user to click on small image and it appears in the larger div. I think the album will work, just trying to figure out how to do what I need.

Re: How to get location of image used in Global Content Bloc

Posted: Mon Jan 09, 2012 2:54 pm
by applejack
Sure it depends on what you need and how you need this so a client can use it. From what you said I would use the core CMS. Just add content blocks for the 5 main images as textarea blocks which they can then use TinyMCE to upload the image and view it. For the thumbnails use the supersizer plugin to auto resize.

If the code requires these to be background images then use regex to strip the img tag.