Advanced search  

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

Pages: [1]   Go Down

Author Topic: Changing ALT Tags  (Read 7125 times)

0 Members and 1 Guest are viewing this topic.

adam625

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 28
Changing ALT Tags
« on: August 12, 2006, 01:20:25 am »

I do not know a whole lot about PHP and I'm trying to change the ALT tags to the pictures within an album. Right now its showing file name, file size, dimensions, and date added. The only one I want is file name only. Also, I don't want it showing file name=file.jpg, I just want it to show as file.jpg. Attached is my theme.php file. Any help changing this would be great!
« Last Edit: August 13, 2006, 08:31:32 am by GauGau »
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: Changing ALT Tags
« Reply #1 on: August 12, 2006, 07:05:33 am »

you can't achive this by editing theme.php

[edit]Actualy there is a way , but I can't code it right now (I should go)! you need to put some extra code under theme_display_thumbnails function and change the $thumb['image'] variable under foreach statment[/edit]

there is a quick and unsafe way:

You need to change function.inc.php !!!
find display_thumbnails function then find (around line 1689)
Code: [Select]
$pic_title =$lang_display_thumbnails['filename'].$row['filename']."\n".
                                $lang_display_thumbnails['filesize'].($row['filesize'] >> 10).$lang_byte_units[1]."\n".
                                $lang_display_thumbnails['dimensions'].$row['pwidth']."x".$row['pheight']."\n".
                                $lang_display_thumbnails['date_added'].localised_date($row['ctime'], $album_date_fmt);
and replace it with this
Code: [Select]
// Mod to show only file name under title
/*$pic_title =$lang_display_thumbnails['filename'].$row['filename']."\n".
                                $lang_display_thumbnails['filesize'].($row['filesize'] >> 10).$lang_byte_units[1]."\n".
                                $lang_display_thumbnails['dimensions'].$row['pwidth']."x".$row['pheight']."\n".
                                $lang_display_thumbnails['date_added'].localised_date($row['ctime'], $album_date_fmt);*/
$pic_title =$row['filename'];

- and keep in mind Modifing function.inc.php is not safe and not recommanded
- I'll write a plugin for this soon
« Last Edit: August 12, 2006, 07:38:27 am by bmossavari »
Logged
‍I don't answer to PM with support question
Please post your issue to related board

adam625

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 28
Re: Changing ALT Tags
« Reply #2 on: August 12, 2006, 05:38:43 pm »

If there is a safer way to do it, I'll prefer to wait till you have some extra time to post the code. Thanks! :)
Logged

adam625

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 28
Re: Changing ALT Tags
« Reply #3 on: August 12, 2006, 05:50:00 pm »

Just as a test I tried the way you suggested by modifying function.inc.php and it did work. Is there a reason why you do not recommend this and that it's unsafe?
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Changing ALT Tags
« Reply #4 on: August 12, 2006, 07:05:39 pm »

Not exactly unsafe, but you'll lose all modifications when updating in the future.
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: Changing ALT Tags
« Reply #5 on: August 12, 2006, 07:11:30 pm »

function.inc.php shouldn't change at any circumstances , it's a core file and we should leave it alone ;)
here is the change you can make to your theme.php to only show the filename under image title:
check your theme for theme_display_thumbnails function and if you have it then replace it with this one and if you don't have then simply copy this code to your theme.php

Code: [Select]
function theme_display_thumbnails(&$thumb_list, $nbThumb, $album_name, $aid, $cat, $page, $total_pages, $sort_options, $display_tabs, $mode = 'thumb')
{
    global $CONFIG;
    global $template_thumb_view_title_row,$template_fav_thumb_view_title_row, $lang_thumb_view, $template_tab_display, $template_thumbnail_view, $lang_album_list;
    global $lang_display_thumbnails; // added by bmossavari for removing some text from image title
    static $header = '';
    static $thumb_cell = '';
    static $empty_cell = '';
    static $row_separator = '';
    static $footer = '';
    static $tabs = '';
    static $spacer = '';

    if ($header == '') {
        $thumb_cell = template_extract_block($template_thumbnail_view, 'thumb_cell');
        $tabs = template_extract_block($template_thumbnail_view, 'tabs');
        $header = template_extract_block($template_thumbnail_view, 'header');
        $empty_cell = template_extract_block($template_thumbnail_view, 'empty_cell');
        $row_separator = template_extract_block($template_thumbnail_view, 'row_separator');
        $footer = template_extract_block($template_thumbnail_view, 'footer');
        $spacer = template_extract_block($template_thumbnail_view, 'spacer');
    }

    $cat_link = is_numeric($aid) ? '' : '&cat=' . $cat;
    $uid_link = (isset($_GET['uid']) && is_numeric($_GET['uid'])) ? '&uid=' . $_GET['uid'] : '';

    $theme_thumb_tab_tmpl = $template_tab_display;

    if ($mode == 'thumb') {
        $theme_thumb_tab_tmpl['left_text'] = strtr($theme_thumb_tab_tmpl['left_text'], array('{LEFT_TEXT}' => $aid == 'lastalb' ? $lang_album_list['album_on_page'] : $lang_thumb_view['pic_on_page']));
        $theme_thumb_tab_tmpl['inactive_tab'] = strtr($theme_thumb_tab_tmpl['inactive_tab'], array('{LINK}' => 'thumbnails.php?album=' . $aid . $cat_link . $uid_link . '&page=%d'));
        $theme_thumb_tab_tmpl['inactive_next_tab'] = strtr($theme_thumb_tab_tmpl['inactive_next_tab'], array('{LINK}' => 'thumbnails.php?album=' . $aid . $cat_link . $uid_link . '&page=%d'));
        $theme_thumb_tab_tmpl['inactive_prev_tab'] = strtr($theme_thumb_tab_tmpl['inactive_prev_tab'], array('{LINK}' => 'thumbnails.php?album=' . $aid . $cat_link . $uid_link . '&page=%d'));
    } else {
        $theme_thumb_tab_tmpl['left_text'] = strtr($theme_thumb_tab_tmpl['left_text'], array('{LEFT_TEXT}' => $lang_thumb_view['user_on_page']));
        $theme_thumb_tab_tmpl['inactive_tab'] = strtr($theme_thumb_tab_tmpl['inactive_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&page=%d'));
        $theme_thumb_tab_tmpl['inactive_next_tab'] = strtr($theme_thumb_tab_tmpl['inactive_next_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&page=%d'));
        $theme_thumb_tab_tmpl['inactive_prev_tab'] = strtr($theme_thumb_tab_tmpl['inactive_prev_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&page=%d'));
    }

    $thumbcols = $CONFIG['thumbcols'];
    $cell_width = ceil(100 / $CONFIG['thumbcols']) . '%';

    $tabs_html = $display_tabs ? create_tabs($nbThumb, $page, $total_pages, $theme_thumb_tab_tmpl) : '';
    // The sort order options are not available for meta albums
    if ($sort_options) {
        $param = array('{ALBUM_NAME}' => $album_name,
            '{AID}' => $aid,
            '{PAGE}' => $page,
            '{NAME}' => $lang_thumb_view['name'],
            '{TITLE}' => $lang_thumb_view['title'],
            '{DATE}' => $lang_thumb_view['date'],
            '{SORT_TA}' => $lang_thumb_view['sort_ta'],
            '{SORT_TD}' => $lang_thumb_view['sort_td'],
            '{SORT_NA}' => $lang_thumb_view['sort_na'],
            '{SORT_ND}' => $lang_thumb_view['sort_nd'],
            '{SORT_DA}' => $lang_thumb_view['sort_da'],
            '{SORT_DD}' => $lang_thumb_view['sort_dd'],
            '{POSITION}' => $lang_thumb_view['position'],
            '{SORT_PA}' => $lang_thumb_view['sort_pa'],
            '{SORT_PD}' => $lang_thumb_view['sort_pd'],
            );
        $title = template_eval($template_thumb_view_title_row, $param);
    } else if ($aid == 'favpics' && $CONFIG['enable_zipdownload'] == 1) { //Lots of stuff can be added here later
       $param = array('{ALBUM_NAME}' => $album_name,
                             '{DOWNLOAD_ZIP}'=>$lang_thumb_view['download_zip']
                               );
       $title = template_eval($template_fav_thumb_view_title_row, $param);
    }else{
        $title = $album_name;
    }


    if ($mode == 'thumb') {
        starttable('100%', $title, $thumbcols);
    } else {
        starttable('100%');
    }

    echo $header;

    $i = 0;
    foreach($thumb_list as $thumb) {
        $i++;
        $thumb_title=$thumb['image'];
          // added by bmossavari for removing some text from image title
                $thumb_title=$thumb['image'];
$thumb_title1=substr($thumb_title,0,strpos($thumb_title,$lang_display_thumbnails['filesize'])-1);
$thumb_title2="\">";
$thumb_title=$thumb_title1.$thumb_title2;
$thumb_title=str_replace($lang_display_thumbnails['filename'],'',$thumb_title);
         //end of mod
if ($mode == 'thumb') {
            if ($aid == 'lastalb') {
                $params = array('{CELL_WIDTH}' => $cell_width,
                    '{LINK_TGT}' => "thumbnails.php?album={$thumb['aid']}",
                    //'{THUMB}' => $thumb['image'],
'{THUMB}' => $thumb_title,
                    '{CAPTION}' => $thumb['caption'],
                    '{ADMIN_MENU}' => $thumb['admin_menu']
                    );
            } else {
                $params = array('{CELL_WIDTH}' => $cell_width,
                    '{LINK_TGT}' => "displayimage.php?album=$aid$cat_link&pos={$thumb['pos']}$uid_link",
                      //'{THUMB}' => $thumb['image'],
'{THUMB}' => $thumb_title,
                    '{CAPTION}' => $thumb['caption'],
                    '{ADMIN_MENU}' => $thumb['admin_menu']
                    );
            }
        } else {
            $params = array('{CELL_WIDTH}' => $cell_width,
                '{LINK_TGT}' => "index.php?cat={$thumb['cat']}",
                  //'{THUMB}' => $thumb['image'],
'{THUMB}' => $thumb_title,
                '{CAPTION}' => $thumb['caption'],
                '{ADMIN_MENU}' => ''
                );
        }
        echo template_eval($thumb_cell, $params);

        if ((($i % $thumbcols) == 0) && ($i < count($thumb_list))) {
            echo $row_separator;
        }
    }
    for (;($i % $thumbcols); $i++) {
        echo $empty_cell;
    }
    echo $footer;

    if ($display_tabs) {
        $params = array('{THUMB_COLS}' => $thumbcols,
            '{TABS}' => $tabs_html
            );
        echo template_eval($tabs, $params);
    }

    endtable();
    echo $spacer;
}
« Last Edit: August 12, 2006, 09:39:13 pm by bmossavari »
Logged
‍I don't answer to PM with support question
Please post your issue to related board

adam625

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 28
Re: Changing ALT Tags
« Reply #6 on: August 12, 2006, 08:32:54 pm »

The code you provided did work by putting it in theme.php, thanks! :) One problem I noticed is that when the ALT tag comes up, it has an extra blank line below the name of the file. What I mean is the ALT tag box is 2 lines long, but the top line only is being used. Let me know if you can to fix this. Thanks again!

By the way you can see an example of what I mean here: http://gallery.adamsphotogallery.com/thumbnails.php?album=58
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: Changing ALT Tags
« Reply #7 on: August 12, 2006, 09:39:58 pm »

okey I change the function on last post ...use the new one
Logged
‍I don't answer to PM with support question
Please post your issue to related board

adam625

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 28
Re: Changing ALT Tags
« Reply #8 on: August 12, 2006, 10:40:02 pm »

Thanks! :) It works perfectly now. Your help has been greatly appreciated!
Logged

domarcel

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Re: Changing ALT Tags
« Reply #9 on: July 11, 2008, 05:39:46 pm »

Hi,
l am new to Coppermine. i just tried your code listed above to copy, but came with error message on home page.
any coding missing.
l am a newbie and don't know much, learning.

Many thanks,
Marcel :)
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Changing ALT Tags
« Reply #10 on: July 11, 2008, 06:04:20 pm »

Without a link to your gallery nor the error message you got, what kind of advice do you expect? ::)
Logged
Pages: [1]   Go Up
 

Page created in 0.022 seconds with 19 queries.