tags:

views:

28

answers:

4

I have a long UL list and each LI contains an image tag, dynamically generated from SLideshowPro Director.

I need to get the widths of ALL the images inside the UL to use in a CSS width calculation.

I have been able to get the image width for the first item, but not all.

My PHP is pretty limited, but do I have to make this list into an ARRAY first to allow me to get all the widths?

And how do i do that??

These images contain very long id's generated by the CMS, so reading through a directory is not possible, as the images in cache bare not relation to the file names that are output to the HTML page. It has to all be done from the content that's sent to the page.

Or could I even use JQuery to do this??

A: 

My advice would be to use Regular Expressions.

If you post an example List I can tell more..

Flexx
A: 

You can get the width of images using javascript.

var img = new Image();
img.onload = function() { alert(img.width); };
img.src= 'http://www.google.se/intl/en_com/images/srpr/logo1w.png';
baloo
A: 

Of top of my head.. something like this

var totalWidth = 0;
$('#idOfYourUL img').each(function(i) {
    totalWidth += parseInt(this.width());
});
Phliplip
Syntax errors, free of charge ;)
Phliplip
A: 

Thanks for your responses.

I am using jquery.scrollTo to click-scroll the list through a div, but scrollTo needs a UL width set in CSS so it will stop at the end of the list.

I hoped to use PHP to echo out a CSS width onto the document by using a simple math calculating the number of thumbnails multiplied by their individual widths.

This is the dev link here.

http://jonasbresnan.com/v2/galleriffic/index.php

Ben Shrimpton