Google referencing: change alt text for images Google referencing: change alt text for images
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Google referencing: change alt text for images

Started by jul, October 19, 2004, 04:23:28 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jul

Hi,

I would like to replace the filename, dimensions, and weight of the images by their caption and keywords in order to make them more accessible from google image search, for example.

I managed to do it for the big images in displayimage.php but have problems with the thumbnails.
I tried to do changes in the functions.inc.php file but I do not get the logic of the thing... Can you help me?

Thanks a lot

Jul 

Joachim Müller

I'm not sure what you actually mean by "weight", but I guess you want to increase the relevance of some keywords on the page, to make them stand out more against navigation elements. You can do this by putting a header (<h1> to <h6>) tag around them, although you have to understand that this will change the way they're displayed as well. I recommend creating css attributes (another class), like this h1.myclass { margin:0px;padding:0px;font-size:9px;}and wrap the title display from the thumbnails page inside tags like this<h1 class="myclass">{actual title}</h1>To do this, edit include/functions.inc.php, find                        $caption = "<span class=\"thumb_title\">";
                        $caption .= ($rowset[$key]['title']||$rowset[$key]['hits']) ? $rowset[$key]['title'] : '';

            if ($CONFIG['views_in_thumbview']){
               if ($rowset[$key]['title']){$caption .= "&nbsp;&ndash;&nbsp;";}
            $caption .= sprintf($lang_get_pic_data['n_views'], $rowset[$key]['hits']);
            }
                 $caption .= "</span>";
and replace with                        $caption = "<h1 class=\"thumb_title\">";
                        $caption .= ($rowset[$key]['title']||$rowset[$key]['hits']) ? $rowset[$key]['title'] : '';

            if ($CONFIG['views_in_thumbview']){
               if ($rowset[$key]['title']){$caption .= "&nbsp;&ndash;&nbsp;";}
            $caption .= sprintf($lang_get_pic_data['n_views'], $rowset[$key]['hits']);
            }
                 $caption .= "</h1>";
. Next, edit themes/yourtheme/style.css, find.thumb_title {
        font-weight : bold;
        font-size: 80%;
        padding: 2px;
        display : block;
}
and replace with.thumb_title {
        font-weight : bold;
        font-size: 10px;
        padding: 2px;
        marging:0px;
        display : block;
}
(not tested though). Do a similar thing for the caption.
Please report if this is what you had in mind and if it works for you as well.

Joachim

Joachim Müller

re-reading your question (second look always helps) I saw you were requesting help on the alt text of images: edit include/functions.inc.php, find                        $thumb_list[$i]['image'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$row['filename']}\" title=\"$pic_title\">";and edit accordingly.

Joachim

jul

#3
Hi Gaugau,

Thanks a lot for your help and sorry for not being clear enough. I was thinking of alt attributes of images because I read it was important if you wanted google images to return your pics in a search list... As the default alt content is blank for the big images and "Filename : xxx.jpg Filesize : xxKB Dimensions : xxx x xxx Date added : xxx xx, xxxx" for the thumbnails, I thought it was helpless for google (or even for people viewing the site with a non-graphic navigator).

As I said, I managed to change the alt for the big picture, in displayimage, which is the most important.
As far as thumbnails are concerned, I found the code to change but I don't know with which function I should replace {$row['filename']}, I tried a couple of solutions as {$row['caption']} or $CURRENT_PIC_DATA['caption'] but it would return a blank alt attribute or would surprisingly display everything in the thumbnail view... I gave up for the moment, as I'm less concerned about the thumbnails.

Thanks for your help!

ps: I apologize for using "weight", I was thinking filesize... Still thinking in french while writing in english ;-)

Joachim Müller

I can see your point if you want the google picture spider to index your gallery, but I doubt there will be many people who use a non-graphical browser who will enjoy browsing a picture gallery, even if you have descriptive texts on the images. In fact, the title and caption are displayed as text below the thumbnails (if you set up coppermine to do so), so they won't miss any information.

However, this modification needs "fiddling" in the core part of coppermine, you have to be very carefull with any modifications. The actual thumbnails are being built within the function display_thumbnails within include/functions.inc.php; all other occurences are being used to generate meta album thumbnails, filmstrip etc.

Joachim

jul

Hi Gaugau,

I agree with you, the non graphical browser users won't stay long in a picture gallery... However, they were not better off when knowing the  fliename of the picture ;-)

I got used to mess around with the functions.inc.php when modifying coppermine for xhtml tableless output, don't worry! I always keep a backup version ;-)

Thanks...

Jul