Jump to content

Recommended Posts

Hi All. I have a photo gallery script that just needs you to have a few lines of code on a page:

 

This and

<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>

This are needed just once on each page

<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />

 

Then this for each image.

<a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a>

 

I was hoping that there is some way that a PHP script could do this each time a photo is uploaded to a directory.

 

So for instance

<a href="could place the image name here" rel="lightbox" title="my caption">And a caption here</a>

 

I was hoping that I could have some help to create a backend with an upload box and 'caption' box. When you upload it, it sends the photo to the directory, then inputs this line of script into the gallery page, along with the caption I provided.

 

Can anyone help me?

 

Thankyou to anyone that helps, or at least gives some tips.

 

Regards

Chris

 

Link to comment
https://forums.phpfreaks.com/topic/106458-feeling-like-a-dumb-ass-please-help/
Share on other sites

If you have access to a database, it would be easier to store the file names an captions there, rather than opening an HTML file and inserting a new image tag for each upload.

 

Edit: And even if you dont have access to a database, it would easier to store file names and captions in a flat file, and parse that in your gallery page.

Ah I see

 

The reason I am doing this to use the gallery lightroom

 

I didnt want anything to complicated

 

I just need a script, using a database or not, to create that line of code for each photo and place it in the script.

 

Is it possible?

ok this is what I would do. I'm guessing you have something like

 

<a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a>

<a href="images/image-2.jpg" rel="lightbox" title="my caption">image #2</a>

<a href="images/image-3.jpg" rel="lightbox" title="my caption">image #3</a>

 

in a file. well make a new file called "imagelinks.txt" (doesn't need to be text, can be whatever you want but I use text, some people use php files. Copy all the links into that file so that file looks like this

 

<a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a>
<a href="images/image-2.jpg" rel="lightbox" title="my caption">image #2</a>
<a href="images/image-3.jpg" rel="lightbox" title="my caption">image #3</a>

 

where that bit of code was on the original document write

 

<?php include('imagelinks.txt'); ?>

 

when you upload imagelinks.txt chmod it to 777

 

 

thats the easy bit, the next bit i would have to see the code of the upload thing to do but I can give a basic guide.

 

open up the upload script file now my code is probably really messed up here so hopefully someone will fix it for you but here is what it should roughly look like

 

 

 

$il = "../path/to/imagelinks.txt"
$cap = ""
$imgnm = ""
$imglnk = ""

^ This code you will need to edit.

$cap is the caption which you will need to pick up for the upload script

$imgnm is the filename, eg "image-2.jpg"

$imglnk is the text that you wil use to link to the image, eg image #3

 

$il = "../path/to/imagelinks.txt"

^ will need changing to where ever the images directory is in relation to the upload script

 

$f1 = "<a href='images/"
$f2 = "' rel='lightbox' title='"
$f3 = "'>"
$f4 = "</a>"

$newline = "$f1 $cap $f2 $imgnm $f3 $imglnk $f4"
$handleil = fopen($il, 'w');
fwrite($handleil, $newline);

-----------

 

 

I hope this helps

 

MadnessRed

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.