473,789 Members | 2,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with dynamically changing captions via img title tag

4 New Member
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 1781
dlite922
1,584 Recognized Expert Top Contributor
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
letshin
4 New Member
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("$dirnameh ttp/$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=="fi lename_from_tex t_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 Recognized Expert Expert
Are you able to use a mysql database?

IT would make things a hell of alot easier.
Mar 11 '08 #4
letshin
4 New Member
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
letshin
4 New Member
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
3930
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 them a caption, storing the caption and filename in a text file. It's a bit buggy when removing the photos and captions from the file, and also in displaying them on the delete page. you can see it in action at www.4am.com.au/gallery/upload.php...
14
2621
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 (that part's not here -- spotlighting the problem code): --------BEGIN CODE PAGE------------ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
9
3730
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
2734
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 usb15@cox.net. Any help would be great.
3
9253
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 http://boxover.swazz.org. There is a demo there as well.
7
3301
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 database or does each machine need to have that font installed? Thanks for any help, ShyGuy
2
2289
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 not showing up, even though it seems to be part of the document (i.e. I can reach the nodes through through document.body.getElementsByTagName... ) var e; var f; // Will hold a document fragment.
2
1832
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: ****************************************************************************** <%@ Page Language="C#" trace="false" debug="true" ContentType="text/html" ResponseEncoding="iso-8859-1" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
0
936
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
10410
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10200
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5418
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3701
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.