Advanced search  

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]

Pages: [1]   Go Down

Author Topic: replace IPTC Title with IPTC Copyright  (Read 8671 times)

0 Members and 1 Guest are viewing this topic.

clemphoto

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
replace IPTC Title with IPTC Copyright
« on: April 01, 2010, 02:01:51 am »

Developing a new photo viewing site, http://clemsonphotos.org/coppermine is the gallery location.  Using 1.5 RC, and every thing seems to work.  But, for my application, I would prefer to have thumbnails and files displayed with something other than the image title below the image.  Due to the nature of the project, the IPTC Copyright field would be more appropriate.  I don't see how this can be done without modifying code, and what and how to modify are not clear.  Is this something that can be done by a user, or should it more properly be viewed as a feature request?

Del
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: replace IPTC Title with IPTC Copyright
« Reply #1 on: April 01, 2010, 07:22:49 am »

Your subject is wrong: you don't replace the IPTC title, but the regular thumbnail title, because that's what actually shows as far as I can see.

Is this something that can be done by a user, or should it more properly be viewed as a feature request?
That's not a feature request, but clearly a matter of custom theme modification, so I'm moving this thread accordingly. A feature request is a request for a feature in a future coppermine release. Your request clearly won't go into a future version; you want a solution now and not in the distant future.

Using 1.5 RC
It's actually cpg1.5.3 RC - that's the official version number.

I would prefer to have thumbnails and files displayed with something other than the image title below the image.  Due to the nature of the project, the IPTC Copyright field would be more appropriate.
This is a request that is very similar to your other thread replace Title with Copyright. All you need to do is take a look at Documentation -> Creating your custom theme ff.
In the first place you need to do as suggested in Rename your theme first. Next, I want you to read Editing theme.php, because that's what we need to do.We'll need to edit the function definition for theme_display_thumbnails, so you'll have to copy that section from the sample theme first into your custom theme, i.e. you copy from themes/sample/theme.php
Code: [Select]
/******************************************************************************
** Section <<<theme_display_thumbnails>>> - START
******************************************************************************/
function theme_display_thumbnails(&$thumb_list, $nbThumb, $album_name, $aid, $cat, $page, $total_pages, $sort_options, $display_tabs, $mode = 'thumb', $date='')
{
    global $CONFIG, $CURRENT_ALBUM_DATA;
    global $template_thumb_view_title_row,$template_fav_thumb_view_title_row, $lang_thumb_view, $lang_common, $template_tab_display, $template_thumbnail_view, $lang_album_list, $lang_errors;

    $superCage = Inspekt::makeSuperCage();

    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) ? '' : '&amp;cat=' . $cat;
    $date_link = $date=='' ? '' : '&amp;date=' . $date;
    if ($superCage->get->getInt('uid')) {
      $uid_link = '&amp;uid=' . $superCage->get->getInt('uid');
    } else {
      $uid_link = '';
    }

    $album_types = array(
        'albums' => array('lastalb')
    );
    $album_types = CPGPluginAPI::filter('theme_thumbnails_album_types', $album_types);

    $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}' => in_array($aid, $album_types['albums']) ? $lang_album_list['album_on_page'] : $lang_thumb_view['pic_on_page']));
        $theme_thumb_tab_tmpl['page_link'] = strtr($theme_thumb_tab_tmpl['page_link'], array('{LINK}' => 'thumbnails.php?album=' . $aid . $cat_link . $date_link . $uid_link . '&amp;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['page_link'] = strtr($theme_thumb_tab_tmpl['page_link'], array('{LINK}' => 'index.php?cat=' . $cat . '&amp;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) : '';

    if (!GALLERY_ADMIN_MODE && stripos($template_thumb_view_title_row, 'admin_buttons') !== false) {
        template_extract_block($template_thumb_view_title_row, 'admin_buttons');
    }
    // The sort order options are not available for meta albums
    if ($sort_options) {
        if (GALLERY_ADMIN_MODE) {
            $param = array(
                '{ALBUM_ID}'   => $aid,
                '{CAT_ID}'     => ($cat > 0 ? $cat : $CURRENT_ALBUM_DATA['category']),
                '{MODIFY_LNK}'     => $lang_common['album_properties'],
                '{MODIFY_ICO}'     => cpg_fetch_icon('modifyalb', 1),
                '{PARENT_CAT_LNK}' => $lang_common['parent_category'],
                '{PARENT_CAT_ICO}' => cpg_fetch_icon('category', 1),
                '{EDIT_PICS_LNK}'  => $lang_common['edit_files'],
                '{EDIT_PICS_ICO}'  => cpg_fetch_icon('edit', 1),
                '{ALBUM_MGR_LNK}'  => $lang_common['album_manager'],
                '{ALBUM_MGR_ICO}'  => cpg_fetch_icon('alb_mgr', 1),
            );
        } else {
            $param = array();
        }
        $param['{ALBUM_NAME}'] = $album_name;
        // Plugin Filter: allow plugin to modify or add tags to process
        $param = CPGPluginAPI::filter('theme_thumbnails_title', $param);
        $title = template_eval($template_thumb_view_title_row, $param);
    } elseif ($aid == 'favpics' && $CONFIG['enable_zipdownload'] > 0) { //Lots of stuff can be added here later
        $param = array(
            '{ALBUM_ID}'   => $aid,
            '{ALBUM_NAME}' => $album_name,
            '{DOWNLOAD_ZIP}' => cpg_fetch_icon ('zip', 2) . $lang_thumb_view['download_zip'],
        );
        // Plugin Filter: allow plugin to modify or add tags to process
        $param = CPGPluginAPI::filter('theme_thumbnails_title', $param);       
        $title = template_eval($template_fav_thumb_view_title_row, $param);
    } else {
        $title = $album_name;
    }
   
    $wrapper_start = CPGPluginAPI::filter('theme_thumbnails_wrapper_start');
    echo $wrapper_start;

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

    echo $header;

    $i = 0;
    global $thumb;  // make $thumb accessible to plugins
    foreach($thumb_list as $thumb) {
        $i++;
        if ($mode == 'thumb') {
            if (in_array($aid, $album_types['albums'])) {
                $params = array(
                    '{CELL_WIDTH}' => $cell_width,
                    '{LINK_TGT}'   => "thumbnails.php?album={$thumb['aid']}",
                    '{THUMB}'      => $thumb['image'],
                    '{CAPTION}'    => $thumb['caption'],
                    '{ADMIN_MENU}' => $thumb['admin_menu'],
                );
            } else {
                // determine if thumbnail link targets should open in a pop-up
                if ($CONFIG['thumbnail_to_fullsize'] == 1) { // code for full-size pop-up
                    if (!USER_ID && $CONFIG['allow_unlogged_access'] <= 2) {
                       $target = 'javascript:;" onclick="alert(\''.sprintf($lang_errors['login_needed'],'','','','').'\');';
                    } elseif (USER_ID && USER_ACCESS_LEVEL <= 2) {
                        $target = 'javascript:;" onclick="alert(\''.sprintf($lang_errors['access_intermediate_only'],'','','','').'\');';
                    } else {
                       $target = 'javascript:;" onclick="MM_openBrWindow(\'displayimage.php?pid=' . $thumb['pid'] . '&fullsize=1\',\'' . uniqid(rand()) . '\',\'scrollbars=yes,toolbar=no,status=no,resizable=yes,width=' . ((int)$thumb['pwidth']+(int)$CONFIG['fullsize_padding_x']) .  ',height=' .   ((int)$thumb['pheight']+(int)$CONFIG['fullsize_padding_y']). '\');';
                    }
                } elseif ($aid == 'random') {
                    $target = "displayimage.php?pid={$thumb['pid']}$uid_link#top_display_media";
                } elseif ($aid == 'lastcom' || $aid == 'lastcomby') {
                    $page = cpg_get_comment_page_number($thumb['msg_id']);
                    $page = (is_numeric($page)) ? "&amp;page=$page" : '';
                    $target = "displayimage.php?album=$aid$cat_link$date_link&amp;pid={$thumb['pid']}$uid_link&amp;msg_id={$thumb['msg_id']}$page#comment{$thumb['msg_id']}";
                } else {
                    $target = "displayimage.php?album=$aid$cat_link$date_link&amp;pid={$thumb['pid']}$uid_link#top_display_media";
                }
                $params = array(
                    '{CELL_WIDTH}' => $cell_width,
                    '{LINK_TGT}'   => $target,
                    '{THUMB}'      => $thumb['image'],
                    '{CAPTION}'    => $thumb['caption'],
                    '{ADMIN_MENU}' => $thumb['admin_menu'],
                );
            }

        } else {  // mode != 'thumb'

            // Used for mode = 'user' from list_users() in index.php
            $params = array(
                '{CELL_WIDTH}' => $cell_width,
                '{LINK_TGT}'   => "index.php?cat={$thumb['cat']}",
                '{THUMB}'      => $thumb['image'],
                '{CAPTION}'    => $thumb['caption'],
                '{ADMIN_MENU}' => '',
            );

        }

        // Plugin Filter: allow plugin to modify or add tags to process
        $params = CPGPluginAPI::filter('theme_display_thumbnails_params', $params);
        echo template_eval($thumb_cell, $params);

        if ((($i % $thumbcols) == 0) && ($i < count($thumb_list))) {
            echo $row_separator;
        }
    } // foreach $thumb

    unset($thumb);  // unset $thumb to avoid conflicting with global

    for (;($i % $thumbcols); $i++) {
        echo $empty_cell;
    }
    $footer = CPGPluginAPI::filter('theme_thumbnails_footer', $footer);
    echo $footer;

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

    endtable();
    $wrapper_end = CPGPluginAPI::filter('theme_thumbnails_wrapper_end');
    echo $wrapper_end;
    echo $spacer;
}
/******************************************************************************
** Section <<<theme_display_thumbnails>>> - END
******************************************************************************/
and paste that into a new line before
Code: [Select]
?>into the file themes/yourtheme/theme.php

Finally you need to populate the title accordingly: find
Code: [Select]
    $wrapper_start = CPGPluginAPI::filter('theme_thumbnails_wrapper_start');in the code you just added and add before that into a new line something like
Code: [Select]
    if ($iptc['Copyright'] != '') {
        $title = $iptc['Copyright'];
    }
We're not done yet - the variable we pasted in doesn't reside inside the scope of the function that we're modifying. So, find
Code: [Select]
    global $CONFIG, $CURRENT_ALBUM_DATA;
    global $template_thumb_view_title_row,$template_fav_thumb_view_title_row, $lang_thumb_view, $lang_common, $template_tab_display, $template_thumbnail_view, $lang_album_list, $lang_errors;
in the code you inserted and add underneath it (into a new line of it's own)
Code: [Select]
    global $iptc;Please report back if this works as expected, as I haven't actually tried my suggestions, but coded it from the back of my head.

I'd really like to see you try a little harder before you ask a question: please give the documentation a try.
Logged

clemphoto

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: replace IPTC Title with IPTC Copyright
« Reply #2 on: April 01, 2010, 05:59:17 pm »

My thinking was that the thumbnail title contains the IPTC Title, and I would prefer it to contain the IPTC Copyright.  Perhaps I need to write in a more detailed and explicit way.  I noted in a reply on another thread the challenge of knowing where to look to effect a change.  That is another challenge in my newness to this.  I assure you, I have read the documentation, to less good effect that I would have wished for the issues I need to resolve.

I will try this, and then expand the scope of my modifications to see how to do the same thing in display of pictures.  I will post here and let you know of my progress, and of course when the issue is resolved.

Del
Logged

Nibbler

  • Guest
Re: replace IPTC Title with IPTC Copyright
« Reply #3 on: April 01, 2010, 08:13:02 pm »

If you simply want to import the IPTC Copyright instead of the IPTC Title, just change picmgmt.inc.php from

Code: [Select]
$title = (isset($iptc['Title'])) ? $iptc['Title'] : $title;

to

Code: [Select]
$title = (isset($iptc['Copyright'])) ? $iptc['Copyright'] : $title;

Then re-add your pictures.
Logged

clemphoto

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: replace IPTC Title with IPTC Copyright
« Reply #4 on: April 01, 2010, 09:39:04 pm »

Considering future software updates, is it better practice to do this in a custom theme, rather than modify picmgt.inc.php?
Logged

Nibbler

  • Guest
Re: replace IPTC Title with IPTC Copyright
« Reply #5 on: April 01, 2010, 10:21:42 pm »

It's not possible to do that in a custom theme - it's not a theme related function.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15761
Re: replace IPTC Title with IPTC Copyright
« Reply #6 on: April 01, 2010, 10:34:36 pm »

Maybe it's possible to accomplish that with a plugin, but I didn't had a look at the code. If it's not possible, we could add a new plugin hook.
Logged

clemphoto

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: replace IPTC Title with IPTC Copyright
« Reply #7 on: April 01, 2010, 10:43:04 pm »

If you simply want to import the IPTC Copyright instead of the IPTC Title, just change picmgmt.inc.php from

Code: [Select]
$title = (isset($iptc['Title'])) ? $iptc['Title'] : $title;

to

Code: [Select]
$title = (isset($iptc['Copyright'])) ? $iptc['Copyright'] : $title;

Then re-add your pictures.
Thanks, Nibbler, I tried this, but the result was blank title, blank  description, blank keywords.  I reversed the change (back to original) and again have IPTC Title, IPTC Caption, and IPTC Keywords.

Del
Logged

clemphoto

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: replace IPTC Title with IPTC Copyright
« Reply #8 on: April 01, 2010, 10:46:48 pm »

It's not possible to do that in a custom theme - it's not a theme related function.
I only mentioned a custom theme because Joachim advised me as above in this thread.  My concern with that approach is that it does not change the value of $title globally, so, for example, I might be able to display it with a file, but not search on it.  And I would need to be sure and change the display of both thumbnails and files.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15761
Re: replace IPTC Title with IPTC Copyright
« Reply #9 on: April 02, 2010, 08:13:58 am »

So you want to insert the IPTC title to the database on file upload and not just to display it on thumbnail.php. Right?
Logged

clemphoto

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: replace IPTC Title with IPTC Copyright
« Reply #10 on: April 02, 2010, 04:03:47 pm »

To the best of my knowledge, the IPTC data are in the database.  I have enabled IPTC data in config, and IPTC keywords are shown.  The string in the Title field (string in $title) appears to come from IPTC Object Name in my photos.  Caption information in cpg correctly comes from IPTC Caption in my jpg files.  Keywords data comes from IPTC Keywords.  This information can be seen at http://clemsonphotos.org/coppermine.

What I would like to see is for $title to contain IPTC Copyright.  And, yes, I would like for this to happen as early in the process as possible, because I would like for users to be able to include the photographer name (IPTC Copyright) in searches.  Further, I surmise that doing it this was would reduce the extent of modification.  Finally, if this is done at time of upload, it need only be done once, rather than changing text as each page is served.

Strictly speaking, Coppermine apparently maps IPTC Object Name to $title.  In addition to Coppermine, Adobe and XnView map the same way, so there is consensus, at least.  I do understand that while IPTC data is somewhat standard, its implementation in various software is less so.

I am trying to be more detailed in my questions and responses in general, not specifically in response to you, Andre.

Del
Logged

clemphoto

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: replace IPTC Title with IPTC Copyright
« Reply #11 on: April 02, 2010, 06:28:36 pm »

Success.  Nibbler, your solution does indeed work.  I did not realize it at the time, but I had updated the fullsize files from the admin tools.  This stripped them of IPTC data.  When I tested to see if your change worked, I used these fullsize files to reload.  In reviewing my files and looking for changes, I just noticed that the file size of the uploaded files for batch upload were different than those on my system.  Testing on a single file showed that using the Update function from Admin Tools will strip the IPTC data and reduce file size for the fullsize files.  Updating thumbnails and intermediate files did not.  I suppose this is because updating thumbs and intermediates does not reload IPTC data or in other ways change the database tables.

With the change in code above, I now display the contents of the IPTC.Copyright field in thumbnails and intermediates, and contents of that field (now in $title) work in the Search page.  Thanks for your help, and sorry for my error in testing.

Del
Logged
Pages: [1]   Go Up
 

Page created in 0.032 seconds with 21 queries.