Changing the alt attributes Changing the alt attributes
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Changing the alt attributes

Started by mreider, May 08, 2006, 04:50:51 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mreider

I'm going crazy - How can I change the alt attributes of all the images? Right now they show filesize etc and I can't figure out what file I need to edit to change this to the actual title of the image.

I've done a search through all files for 'alt="' and still haven't found the right one.

I'm using CPG 1.4.5.

If someone could point me in the right direction of which file needs to be edited thatd be great. I looked at other threads and couldn't find an answer either, sorry if I missed one.

Stramm

Copy function theme_html_picture() from themes/sample/theme.php to the theme.php you're using. Within that function look for the img tag and modify it to your needs. That's for the intermediate view...

mreider

Thanks, I managed to get that working.

What I'm trying to do though is have the alt attribute set as the pictures title.

I've tried this code:

$pic_html = "<img src=\"" . $picture_url . "\" {$image_size['geom']} class=\"image\" border=\"0\" alt=\"{TITLE}\" /><br />\n";

But that just changes the alt to "{TITLE}".

Do you know how to get it to render the actual title? Do I have to pull it somehow in a different variable?

Thanks again
-Matt

Stramm

instead of TITLE
try
$CURRENT_PIC_DATA['title']

mreider

That did the trick! Now I can play with a few other settings :)

Thanks again Stramm

mreider

Or actually one quick questoin if you happen to know the answer off hand - Do you know where to modify the title attributes for the thumbnails that appear on the index.php?

Stramm

function theme_display_thumbnails  ;)
that's globally for all thumbs (not just the thumbs on index and not for the album thumbs on the index)

mreider

Thanks Stramm.

I found the function, but can't find the title="whatever" in it.

Is there somewhere that is defined? Or am I just missing it?


Stramm

sorry, it's in include/functions.inc.php - function display_thumbnails

replace
                        $thumb_list[$i]['image'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$row['filename']}\" title=\"$pic_title\"/>";

with
                        $thumb_list[$i]['image'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$row['filename']}\" title=\"{$row['title']}\"/>";

mreider

Exactly what I was looking for!

Thanks Stramm - I also installed your mod pack, and it's working beautifully. Thanks for all your contributions.
;D

Seleno

i really don't understand it
in function theme_html_picture()  there are much text,
i'm using version 4.6,can you help me and add file here plz?...so i can replace it
i want the title and the name of pictures to alt also,
waiting your help

Seleno

thanx Stramm ,i see the picture title in alt now but only for thumbnails
but in display image when i point to pic i still see: click to view full size image
so how can i edit it to add the image title as alt?

Stramm

as said, just look for the img tag in the function theme_html_pictures and modify it to your needs
then that's the relevant part for you in that function
            $pic_html = "<a href=\"javascript:;\" onclick=\"MM_openBrWindow('displayimage.php?pid=$pid&amp;fullsize=1','" . uniqid(rand()) . "','scrollbars=yes,toolbar=no,status=no,resizable=yes,width=$winsizeX,height=$winsizeY')\">";
            $pic_title = $lang_display_image_php['view_fs'] . "\n==============\n" . $pic_title;
            $pic_html .= "<img src=\"" . $picture_url . "\" class=\"image\" border=\"0\" alt=\"{$lang_display_image_php['view_fs']}\" /><br />";
            $pic_html .= "</a>\n";
        } else {
            $pic_html = "<img src=\"" . $picture_url . "\" {$image_size['geom']} class=\"image\" border=\"0\" alt=\"\" /><br />\n";

Seleno

hi there
i added this title=\"{$row['title']}\"/>";
but it didn't work with me
when i put mouse in image i still see:
click to view full size image
so how can i add the image title as the image alt,so it will appear as:
image alt and click to view full size or only image title alt
can you fix it for me plz?

Joachim Müller

that's made-up code. There's no constant named title. Do as suggested in the previous posting.

Walkinman

hello Folks,

I made the adjustment show here by Stramm for the intermediate image, and I managed to get it right. Works great, thank you. However, I would also like to adjust the alt tag on the thumbnails page, and can't seem to get it to work. How do I make the alt tags for the thumbnails be the title I have coded in my IPTC data? I would also like the little yellow box that pops up when I mouse over a thumbnail to be the caption from the IPTC data. Are you saying I should adjust the include/functions.inc.php code? I thought I had read on here numerous times never to make adjustments to that code.

Any help is very much aprpeciated, as always.

Thank you.

Cheers

Carl


Walkinman

Hey Stramm,

Yes, I had read that, but just now re-read it (thanks).  I made the changes and it works great, thank you. I thought I had seen people here say never to change that file, so I wasn't sure if that's what I was supposed to do.

Thanks for your patience.

Cheers

Carl

Stramm

you're absolutely right, the right way to do it is to copy that function to the theme.php you're actually using (from themes/sample/theme.php to eg. themes/classic/theme.php) and then do the editing

Walkinman

Hey Stramm,

Ahhhh .. uh oh .. I'll, errr, be right back.

Thanks man.

Cheers

Carl