PDA

View Full Version : PHP Photo Album script adding info



robertaussie
03-03-2008, 11:43 AM
i have found the post to change the title from photo to the acual image name but i was wondering if it was possable to get it to display an img tag and the acual address of the image in the title for eg: like this

[ IMG]http://www.mysite.com/gallery/photo1.gif[/IMG ] like what photobucket has, it gives you the img tags and the complete address so all you do is copy and paste the link. i had to put the spaces in the img tags to get them to show as they was trying to display an image.

i have got it to display it all except the img tags as i do not know how to put them into the script without it erroring

jscheuer1
03-04-2008, 05:10 AM
I'm not sure what you are talking about. But the information is contained in the script and can be made to appear various places. It seems to me that you are editing the buildimage function. If so, what do you have so far? If not, just what post are you referring to, and what have you done?

Also:

Please post a link to the page on your site that contains the problematic code so we can check it out.

robertaussie
03-04-2008, 07:46 AM
here is the part of the code i have changed the part in red is what i have altered


function buildimage(i){
var imagecompletepath=(targetlinkdir!="")? targetlinkdir+galleryarray[i][0] : imagepath+galleryarray[i][0]
var tempcontainer='<a href="'+imagecompletepath+'" target="'+href_target+'" onClick="return popuplinkfunc(this)">'
tempcontainer+='<img src="'+imagepath+galleryarray[i][0]+'" title="'+galleryarray[i][0]+' ['+galleryarray[i][1]+']" />'
tempcontainer+='</a><br />'
tempcontainer+=imagepath+galleryarray [i][0];
return tempcontainer
}

so it displays the full image address like http:///www.mysite.com/gallery/image1.gif but what i am after is how would i get it to dispaly the img tags in it at the start and end of the display like in this pic. like you can display image tages in the forum if you use the open and close img tages with the brackets that is what i want to display on the screen with the full address so all you have to do is copy and past the address with the img tags enclosed with it so you do not have to add them

jscheuer1
03-04-2008, 12:49 PM
OK, looks like (from your attached image) you want it to display both the raw path and filename as well as this pseudo tagged path and filename below that. Change:


tempcontainer+=imagepath+galleryarray [i][0];

to:


tempcontainer+=imagepath+galleryarray [i][0]+'<br>[img]'+imagepath+galleryarray [i][0]+'[\/img]';

Or, as it looks like you might want a little extra space between the two:


tempcontainer+=imagepath+galleryarray [i][0]+'<div style="margin-top:1ex;text-align:center;">[img]'+imagepath+galleryarray [i][0]+'[\/img]<\/div>';

Or, if you want only this pseudo tagged text:


tempcontainer+='[img]'+imagepath+galleryarray [i][0]+'[\/img]';

Just make sure that the .slideshow class (as well as any containing elements for it) have enough width and height to display all of this information. I believe that in the default configuration for this script, it already does.

robertaussie
03-04-2008, 06:45 PM
thanks a lot .. that is what i wanted .. sorry for all the confussion in asking my question but it is exactly what i wanted .

next question is i changed it a little to do more of what i wanted and it works good except when i click the text to hightlight it i get an error when i test it.. here is the full code and the part i changed is in red and a pic is at the bottom to show the error or you can goto http://www.robleeaussie.com/pictures/ to test it .. i know i am missing something in there for the onclick but i am not sure what it is ..


<script src="http://www.robleeaussie.com/pictures/getpics.php" type="text/javascript"></script>

<script type="text/javascript">

/***********************************************
* PHP Photo Album script- Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/

var dimension="4x4" //Specify dimension of gallery (number of images shown), such as 4x2, 3x1 etc
var imagepath="http://www.robleeaussie.com/pictures/" //Absolute path to image directory. Include trailing slash (/)
var href_target="new" //Enter target attribute of links, if applicable

//Toggle popup link setting: popupsetting[0 or 1, "pop up window attributes" (if 1)]
var popupsetting=[1, "width=500px, height=400px, scrollbars, location, resizable"]

//Toggle image description: descriptionprefix[0 or 1, "Text to show" (if 1)]
var descriptionprefix=[0, "Photo "]

//Sort images by date? ("asc", "desc", or "")
//"desc" for example causes the newest images to show up first in the gallery
//"" disables this feature, so images are sorted by file name (default)
var gsortorder="desc"

//By default, each image hyperlinks to itself.
//However, if you wish them to link to larger versions of themselves
//Specify the directory in which the larger images are located
//The file names of these large images should mirror those of the original
//Enter a blank string ("") to disable this option
var targetlinkdir="http://www.robleeaussie.com/pictures/"

/////No need to edit beyond here///////////////////

function sortbydate(a, b){ //Sort images function
if (gsortorder=="asc") //sort by file date: older to newer
return new Date(a[1])-new Date(b[1])
else if (gsortorder=="desc") //sort by file date: newer to older
return new Date(b[1])-new Date(a[1])
}

if (gsortorder=="asc" || gsortorder=="desc")
galleryarray.sort(sortbydate)

var totalslots=dimension.split("x")[0]*dimension.split("x")[1]

function buildimage(i){
var imagecompletepath=(targetlinkdir!="")? targetlinkdir+galleryarray[i][0] : imagepath+galleryarray[i][0]
var tempcontainer='<a href="'+imagecompletepath+'" target="'+href_target+'" onClick="return popuplinkfunc(this)">'
tempcontainer+='<img src="'+imagepath+galleryarray[i][0]+'" title="'+galleryarray[i][0]+' ['+galleryarray[i][1]+']" />'
tempcontainer+='</a><br />'
tempcontainer+='<div style="font-size:10" width="100"><input name="txtThumbImgTag2" id="txtThumbImgTag2" class="textBox" type="text" value="[img]'+imagepath+galleryarray [i][0]+'[\/img]" onclick="trackCodeClick(event); copyToClipboard(this);"></div>';
return tempcontainer
}

function jumptopage(p){
var startpoint=(p-1)*totalslots
var y=1;
for (i=0; i<totalslots; i++){
document.getElementById("slide"+i).innerHTML=(typeof galleryarray[startpoint+i]!="undefined")? buildimage(startpoint+i) : ""
}
while(document.getElementById("navlink"+y)!=null){
document.getElementById("navlink"+y).className=""
y++
}
document.getElementById("navlink"+p).className="current"
}

var curimage=0
for (y=0; y<dimension.split("x")[1]; y++){
for (x=0; x<dimension.split("x")[0]; x++){
if (curimage<galleryarray.length)
document.write('<div id="slide'+curimage+'" class="slideshow">'+buildimage(curimage)+'</div>')
curimage++
}
document.write('<br style="clear: left" />')
}

function popuplinkfunc(imgsrc){
if (popupsetting[0]==1){
var popwin=open(imgsrc.href, "popwin", popupsetting[1])
popwin.focus()
return false
}
else
return true
}

</script>

<!--Below HTML code refers to the navigational links for the gallery-->

<div id="navlinks">
<script type="text/javascript">
for (i=1; i<Math.ceil(galleryarray.length/totalslots)+1; i++)
document.write('<a id="navlink'+i+'" href="javascript:jumptopage('+i+')\">Page'+i+'</a> ')
document.getElementById("navlink1").className="current"
</script>
</div>

robertaussie
03-05-2008, 09:24 AM
forgot to mention that the only thing on line 27 is </script>

jscheuer1
03-05-2008, 01:16 PM
forgot to mention that the only thing on line 27 is </script>

The error messages in IE often refer to the previous line. No error here in IE. I take it that you are using an older version of IE. I can tell you are by the screenshot of the error message. I just tested back through v 5. It was OK, I got errors in v 4, but it was for different lines. v 4 doesn't support this script.

You wouldn't happen to be using a Mac?

robertaussie
03-05-2008, 06:53 PM
no i am not on a mac i am on vista and have ie7 and sorry it was line 127 what is supose to happen is when you clcik in the box where the text is, it is supose to highlight the whole lot, but when i click in the box i get the error on the bottom left, it gives me a little yellow triangle and tells me error on page, to me i think it is looking for a close tag or something but i have tried all sorts of things but nothing seams to work.. the reason i am trying to do it that way is because the text takes up a lot of space and you only get about 3 pocs across the page because of the text, this way it is smaller and i will fit more pics across and also looks neater

jscheuer1
03-05-2008, 07:47 PM
This is the line:


tempcontainer+='<div style="font-size:10" width="100"><input name="txtThumbImgTag2" id="txtThumbImgTag2" class="textBox" type="text" value="[img]'+imagepath+galleryarray [i][0]+'[\/img]" onclick="trackCodeClick(event); copyToClipboard(this);"></div>';

trackCodeClick is not defined. I don't think you should be doing this though, you cannot copy to clipboard using client side code, except in IE and even there it can easily be blocked. When it isn't blocked, it will overwrite the user's clipboard, which can be very inconvenient at times for the user.

You could have the data highlighted onclick to make it ready for copying, by changing:


onclick="trackCodeClick(event); copyToClipboard(this);"

to:


onclick="this.focus();this.select();"

robertaussie
03-05-2008, 07:54 PM
thanks a lot ,, that did the trick .. woohooo it works now ..

jscheuer1
03-06-2008, 02:23 AM
Great! Just as a side note, as I don't run Vista and have no intention of doing so, at least not in the near term, until more of the bugs are worked out . . . So - it looks from your previous screenshot that Vista is reverting to the older IE error message format, or - did you configure it to be like that?

robertaussie
03-06-2008, 06:09 AM
vista is like xp where you can change your windows theme .. for some reason i like the look of the old 98 look .. that is all i have done .. and i am only trying vista to see how it works as i have a few friends on it and don't know nothing about it .. so really all it is for is for knowledge