Monday, 28 March 2011

Creating Div For Photo image and Photo Title

I wanted to combine the photo title and photo image from the photo feed so each photo had a caption, to do this I did the same process as re-sizing each photo, but used concatenation to create different divs

// for each function loads photoitem, parameter in which if the counter for the photos is less than 6 + 1 photo
foreach ($photoxml->channel->item as $photoitem) {
	if($photocounter < 20){
	    $photocounter=$photocounter+1;
}  
// this is the proccess to create a new div for each photo, combining both the photo guid and the photo title (caption)
if($photo2counter < 20){
	    $photo2counter=$photo2counter+1;
}  
	//loads rss feed variable of the image, concatination used to add a counter e.g. 1,2,3... to each photo so that they can be individually edited - using css ID, however had to apply ID to the image source not ID for css styles to work
	// also loads the description under each picture to explain what they the picuture shows. 
	print "
$photoitem->title
"; print "\n"; if($photocounter==20){ break; } }

Now the photo and the photo caption move around together when I change the positioning of them using CSS (sample selection below)

#photodiv1 {
position: relative; left: 0px; top: 0px; 
z-index: 100; 
color: #FFFFFF;
font-size: 16px;
text-shadow: 0px 2px 3px #555;
font-weight:900;
}
#photodiv2 {
position: relative; left: 0px; top: 0px; 
z-index: 100; 
color: #FFFFFF;
font-size: 16px;
text-shadow: 0px 2px 3px #555;
font-weight:900;
}
#photodiv3 {
position: relative; left: 0px; top: 0px; 
z-index: 100; 
color: #FFFFFF;
font-size: 16px;
text-shadow: 0px 2px 3px #555;
font-weight:900;
}


The css and the php produce in the HTML:


is sitting at the couch!

is weight lifting

this is my wall

No comments:

Post a Comment