Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    Regular Coder
    Join Date
    Oct 2003
    Location
    The wild blue yonder
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding an alt attribute to an image link through php

    Hello all,

    First of all, let me say that I know very little about php, and have just about reached my limit with this one.

    I use SPGM for a photo gallery script on my website. Test site is here.

    Now, you can see the little folder images. What I'd very much like to do is add an ALT attribute to those images. Now, I WAS able to do this same thing (but with a title attribute) to the text links right next to the images. Hover over the text links to see. That's not native of SPGM. I added it.

    But I can't figure out how to do the same thing to the images themselves! It's driving me quite crazy.

    I made a text file version of the php file that controls everything for the script so you can see it here. Could someone have a look, please, and help me figure this out? Mucho appreciated!

    Chris

  • #2
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    That is one bloated script.

    You should start from scratch and use a PHP/MySQL image gallery. With MySQL you can have a unique img alt for each image.
    Leonard Whistler

  • #3
    Regular Coder
    Join Date
    Oct 2003
    Location
    The wild blue yonder
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Len Whistler
    That is one bloated script.

    You should start from scratch and use a PHP/MySQL image gallery. With MySQL you can have a unique img alt for each image.
    While I appreciate the thought, that doesn't help. I did not write it. Nor can I start from scratch because I don't know php. It is a bit bloated, yes, but it's also easy, extremely portable, and valid XHTML 1.0 Strict.

    How many php-written ANYTHING is that? Not too many.

    Anyone know how I can add this attribute? It HAS to be possible. I already did it to on portion.

    Chris

  • #4
    Regular Coder
    Join Date
    Dec 2002
    Location
    UK
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmm?

    You just want the image to have tooltip text?

    <img src="file.jpg" alt="text here" />

  • #5
    Regular Coder
    Join Date
    Oct 2003
    Location
    The wild blue yonder
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by bfsog
    Hmm?

    You just want the image to have tooltip text?

    <img src="file.jpg" alt="text here" />
    LOL, I wish it were that simple. I can't add it that way. The HTML file you see through "View Source" is generated from the php file I linked to. The tooltip text has to be added somewhere in there. I just don't know where, and can't find it.

    Chris

  • #6
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Quote Originally Posted by cjwsb
    It HAS to be possible. I already did it to on portion.
    You must have added the img alt to one portion of an if/else statement. Go back and add the img alt info to the rest of the block of code.
    Leonard Whistler

  • #7
    Regular Coder
    Join Date
    Oct 2003
    Location
    The wild blue yonder
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Len Whistler
    You must have added the img alt to one portion of an if/else statement. Go back and add the img alt info to the rest of the block of code.
    Well, that's exactly what I'm having trouble with. WHAT block of code? I appreciate your guys help, I really do. I'm just frustrated as hell because I've gotten so close to my goal on my own (even without knowing php at all) only to get hung up now.

    Ok, if you look at the source code of the page, you'll see this:
    Code:
    <td class="td-galitem-title"><img alt="Just a transparent spacer image" src="http://www.chrisbartlett.net/pix/spacer.png"/>
      <a title="Enter the Cityscape Photos gallery here" href="index.html?spgmGal=Cityscape_Photos" class="td-galitem-title">Cityscape Photos</a>
    I was able to add the ALT and the spacer images because I noticed the "class="td-galitem-title". From that, I was able to find out where to add what I needed in the php file. Basically just methodical detective work and luck.

    Now, the other code in the source is this:
    Code:
    <a href="index.html?spgmGal=Cityscape_Photos" class="td-galitem-title"><img src="flavors/default/folder.jpg" alt="" class="img-folder" width="46" height="44" /></a>
    I need to add an ALT attribute to that so it's not blank. But if you'll notice, it uses the same class. Now, I have looked everywhere (including the same block of code that I added all the above crap to) and can't find squat.

    The only other idea I had was the class="img-folder" could be what I wanted. Doesn't seem to be. I did find this in the php file:
    Code:
    // key in $cfg | ALT value | CLASS value | alternative (if resource is N/A)
    array('gallerySmallIcon', '', CLASS_IMG_FOLDER, ''),
    array('galleryBigIcon', '', CLASS_IMG_FOLDER, '&raquo;'),
    But what does that tell me?!

    I'd really appreciate it if someone could help me figure this out. It's gotta be something simple that I just don't see...

    Chris

  • #8
    Regular Coder
    Join Date
    Oct 2003
    Location
    The wild blue yonder
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wait a sec!

    I DID IT! Well, sorta...

    Ok, it's now
    Code:
    // key in $cfg | ALT value | CLASS value | alternative (if resource is N/A)
    array('gallerySmallIcon', 'Enter the '.$strHtmlGalleryName.' gallery here', CLASS_IMG_FOLDER, ''),
    array('galleryBigIcon', 'Enter the '.$strHtmlGalleryName.' gallery here', CLASS_IMG_FOLDER, '&raquo;'),
    Great, but one other thing. If you go to the site and hover over the TEXT link right next to the folder icon, let's say the landscape gallery, it says, "Enter the Landscape Photos gallery here". However, by hovering over the icon itself, you'll only get, "Enter the gallery here". Why is the '.$strHtmlGalleryName.' variable (is that the right term?!) not working?

    Chris

  • #9
    Regular Coder
    Join Date
    Dec 2002
    Location
    a bit west of pittsburgh
    Posts
    236
    Thanks
    1
    Thanked 0 Times in 0 Posts
    i know it's off topic here, but can you comment out that Begin statement at the end of the page in the JS.

    <!-- // Begin

  • #10
    Regular Coder
    Join Date
    Oct 2003
    Location
    The wild blue yonder
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by joeframbach
    i know it's off topic here, but can you comment out that Begin statement at the end of the page in the JS.

    <!-- // Begin
    Ummmm... Well, sure. But might I ask why?

    Chris

    PS. I used to live around Pittsburgh; in Oakmont, Gibsonia, & Bethel Park! Geatest city on earth, man.

  • #11
    Regular Coder
    Join Date
    Dec 2002
    Location
    a bit west of pittsburgh
    Posts
    236
    Thanks
    1
    Thanked 0 Times in 0 Posts
    it's just floating there. if you did something like that in a more structured language, you'd get some kind of "identifier expected" exception, or something.

  • #12
    Regular Coder
    Join Date
    Oct 2003
    Location
    The wild blue yonder
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok,

    I'll get around to changing it soon. Can anyone PLEASE help me figure out this php problem.

    It's pretty important to me for WCAG-3 compatibility reasons.

    I know it's a big php file with crappy formatting, but I'd really appreciate it if someone could tackle this.

    Chris

  • #13
    Regular Coder
    Join Date
    Dec 2002
    Location
    a bit west of pittsburgh
    Posts
    236
    Thanks
    1
    Thanked 0 Times in 0 Posts
    change lines 925 and 953 to
    Code:
    print ' alt="Enter the '.$strHtmlGalleryName.' gallery here" class="'.CLASS_IMG_GALICON.'" />';
    and see where it goes from there.

  • #14
    Regular Coder
    Join Date
    Dec 2002
    Location
    a bit west of pittsburgh
    Posts
    236
    Thanks
    1
    Thanked 0 Times in 0 Posts
    hmm. it could also be lines 427 and 428.
    Code:
    array('gallerySmallIcon', 'Enter the '.$strHtmlGalleryName.' gallery here', CLASS_IMG_FOLDER, ''),
    array('galleryBigIcon', 'Enter the '.$strHtmlGalleryName.' gallery here', CLASS_IMG_FOLDER, '&raquo;'),

  • #15
    Regular Coder
    Join Date
    Oct 2003
    Location
    The wild blue yonder
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by joeframbach
    hmm. it could also be lines 427 and 428.
    Code:
    array('gallerySmallIcon', 'Enter the '.$strHtmlGalleryName.' gallery here', CLASS_IMG_FOLDER, ''),
    array('galleryBigIcon', 'Enter the '.$strHtmlGalleryName.' gallery here', CLASS_IMG_FOLDER, '&raquo;'),
    It already IS that, unless I'm somehow reading it wrong.

    Chris


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •