473,396 Members | 1,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help with dynamically changing captions via img title tag

Hello!

I have been trying to write a script that changes the title tag of my images. This is because I'm using a script to generate an image gallery, which I linked to a lightbox. I need to put a caption to the images cause well, I think the visitors would like to know what they're looking at :p/ Thing is, I am absolutely clueless now. I have a vague idea though, which is basically to have a text file containing lines with things like,

img1.jpg, This is your caption
and so on

Which I'd access using fopen and fget, split it using explode, loop the lines into an array, match it to $filename using an if statement and change the $title tag accordingly. My previous experience of PHP is from copying and pasting scripts and modifying them. XD

I'd really, really appreciate some help here. Thanks! :p
Mar 11 '08 #1
5 1761
dlite922
1,584 Expert 1GB
So how are you doing it now? If you use lightbox, can you post the relative code?

you should be able to read their PHP code unless its obfuscated (scrambled) in that case, Good luck.

Those images and captions have to be stored somewhere, a file and explode is good if the file is not large. otherwise create a database and consider pagation methods.

Is your question how to modify lightbox photo gallery to also store title of image?
Mar 11 '08 #2
Edit: Posted code doesn't show itself so I removed it. Think its too long. But if you google galerie.php, you should be able to find the script. Its distributed under GNU public licence.

At line 330,
else echo('<a href="' . html("$dirnamehttp/$filename") . '" rel="ibox');

I think I should add a title="$title"
where $title is gotten from a delimited text file which consists of the filename and the title tag. Since the original script already has a $filename variable, I thought of doing something like
if ($filename=="filename_from_text_file")
$title = "caption from text file"

But, like i said I can't program at all / very well in php, so I have no idea what to do..Haha. I only have a general sort of idea.
Mar 11 '08 #3
Markus
6,050 Expert 4TB
Are you able to use a mysql database?

IT would make things a hell of alot easier.
Mar 11 '08 #4
Are you able to use a mysql database?

IT would make things a hell of alot easier.
Yup. I am able to use a database. But I'm trying not to make the things too complicated since the site I'm making is a volunteer job. Once I'm done, it'll be up to my bosses to update the site. As it stands now, I have a few folders of different types of images. Each folder has a set of css, javascript and the gallery generation php script. I thought that I might me able to modify the existing script so that all I need to do is to add a text file containing filenames and scripts to each folder.

Is that possible?
Mar 12 '08 #5
Hey guys. I finally came up with something but I get this fatal error message. Sigh, programming is driving me nuts. Any idea how I can fix it?

Fatal error: Can't use function return value in write context in /Users/leongz/Sites/images/web pics/hanem/gall.php on line 335

Expand|Select|Wrap|Line Numbers
  1. $filetext = "text.txt"; // File which holds all data
  2.  
  3.     $arrFp = file( $filetext ); // Open the data file as an array
  4.     $numLines = count( $arrFp ); // Count the elements in the array
  5.  
  6.     for($j=0; $j<=$numLines; $j++) // Loop through the lines of the text file
  7.     {
  8.         if(strstr($arrWords[$i],':') == $filename){ 
  9.         strstr($arrWords[$i],':',true) = $title
  10.         }            //Line 335 is here.
  11.     }
  12.  
Mar 12 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give...
14
by: Akbar | last post by:
Hey there, Big-time curiosity issue here... Here's the test code (it's not that long)... it's to display a large number of image links with captions, ideally pulled in from an external file...
9
by: pablo | last post by:
Dear NGers, I would like to change the alt-text with the changing of the image during a mouseover action. Can document.images.altView be changed dynamically? TIA, pablo
4
by: CB US 77 | last post by:
I use a piece of javascript to create a photo gallery slideshow. The slideshow part works great, but I would like to add captions to each picture. If you want to see the html, send me an email to...
3
by: Oliver Bryant | last post by:
I just finished developing a javascipt component allowing floating captions to appear over HTML elements. If anyone wants to check it out you can see specs and download it from...
7
by: Shyguy | last post by:
I have an option group with about 30 options. I would like to have the Option Labels get their text from a table. Is this possible, and if so how? Also, is it possible to embad a font into a...
2
by: ezmiller | last post by:
Hi, I have some code (which I will paste in below) that writes out some HTML dynamically using the W3C DOM...the last part of the code write out a simple table. MY problem is that the table is...
2
by: tshad | last post by:
Is there a way to dynamically add in User Controls where I would get the name from a session variable: If I have the following code:...
0
by: Tobias Maier | last post by:
hello I can't retrieve the windows captions / -titles from processes on Windows Server 2003. On Windows XP all works fine. I use the following: - win32 api FindWindow (by title)
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.