forum.coppermine-gallery.net
Support => cpg1.5.x Support => cpg1.5 themes (visuals) => Topic started by: SolidSnake2003 on July 15, 2014, 03:34:58 pm
-
Looking at the themes.inc file in the includes folder. I found the display_thumbnails function. I am curious if this is how to customize the nopic thumbnail picture. How can it be changed?
/******************************************************************************
** 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) ? '' : '&cat=' . $cat;
$date_link = $date=='' ? '' : '&date=' . $date;
if ($superCage->get->getInt('uid')) {
$uid_link = '&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 . '&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 . '&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;
}
CPGPluginAPI::action('theme_thumbnails_wrapper_start', null);
if ($mode == 'thumb') {
starttable('100%', $title, $thumbcols);
} else {
starttable('100%');
}
$header = CPGPluginAPI::filter('theme_thumbnails_header', $header);
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)) ? "&page=$page" : '';
$target = "displayimage.php?album=$aid$cat_link$date_link&pid={$thumb['pid']}$uid_link&msg_id={$thumb['msg_id']}$page#comment{$thumb['msg_id']}";
} else {
$target = "displayimage.php?album=$aid$cat_link$date_link&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();
CPGPluginAPI::action('theme_thumbnails_wrapper_end', null);
echo $spacer;
}
/******************************************************************************
** Section <<<theme_display_thumbnails>>> - END
******************************************************************************/
-
link: http://www.solidsnakelegacy.net/gallery
-
The easiest way would be to replace the images/thumbs/thumb_nopic.png image with a custom image that has the same filename.
Not recommended (also lost during upgrades):
If you want to change the path or name of the image
edit include/functions.inc.php
Find:
$filepathname = 'images/thumbs/thumb_nopic.png';
Change to whatever you wish.
Looking at the themes.inc file in the includes folder.
Look at themes/sample/theme.php instead for any theme edits.
http://documentation.coppermine-gallery.net/en/theme_theme_php.htm#theme_sample
<!--Coppermine Photo Gallery 1.5.20 (stable)-->
Please Upgrade Now!
http://forum.coppermine-gallery.net/index.php/topic,77376.0.html
http://forum.coppermine-gallery.net/index.php/topic,77654.0.html
-
I want to tie the nopic thumbnail to the theme so that way I don't have to worry about overriding the file during upgrades. I have read the documentation, and know not to edit the themes.inc file. I read in the docs that anything in the themes.inc file can be added to the theme.php file, and anything in the theme.php file overrides how the themes.inc file is set up without effecting upgrades.
-
Please upgrade first
http://documentation.coppermine-gallery.net/en/upgrading.htm#upgrade_why
Off the top of my head I can't think of an exact way to replace the nopic thumb in a theme.
I read in the docs that anything in the themes.inc file can be added to the theme.php file
Copy from sample/theme.php instead.
From sample/theme.php
I imagine it would have something to do with replacing the line
$pic_thumb_url = get_pic_url($CURRENT_PIC_DATA,'thumb');
in
/******************************************************************************
** Section <<<theme_html_picture>>> - START
******************************************************************************/
with a modified copy of the get_pic_url function.
which you can add to your custom theme.php
Maybe someone will get back to you before I can tomorrow.
-
Maybe someone will get back to you before I can tomorrow.
I'll have a look 8)
-
Copy the function theme_display_thumbnails from themes/sample/theme.php to your theme's theme.php file, if it doesn't exist.
Find
foreach($thumb_list as $thumb) {
and below, add
if (strpos($thumb['image'], 'images/thumbs/thumb_nopic.png')) {
$thumb['image'] = str_replace('images/thumbs/thumb_nopic.png', 'themes/your_theme_name/your_images_folder/your_logo.png', $thumb['image']);
}
-
Thanks Andre, what kind of mods need to be added do the display_albums sections?
/******************************************************************************
** Section <<<theme_display_album_list>>> - START
******************************************************************************/
function theme_display_album_list(&$alb_list, $nbAlb, $cat, $page, $total_pages)
{
global $CONFIG, $STATS_IN_ALB_LIST, $statistics, $template_tab_display, $template_album_list, $lang_album_list;
$theme_alb_list_tab_tmpl = $template_tab_display;
$theme_alb_list_tab_tmpl['left_text'] = strtr($theme_alb_list_tab_tmpl['left_text'], array('{LEFT_TEXT}' => $lang_album_list['album_on_page']));
$theme_alb_list_tab_tmpl['page_link'] = strtr($theme_alb_list_tab_tmpl['page_link'], array('{LINK}' => 'index.php?cat=' . $cat . '&page=%d'));
$tabs = create_tabs($nbAlb, $page, $total_pages, $theme_alb_list_tab_tmpl);
$album_cell = template_extract_block($template_album_list, 'album_cell');
$empty_cell = template_extract_block($template_album_list, 'empty_cell');
$tabs_row = template_extract_block($template_album_list, 'tabs');
$stat_row = template_extract_block($template_album_list, 'stat_row');
$spacer = template_extract_block($template_album_list, 'spacer');
$header = template_extract_block($template_album_list, 'header');
$footer = template_extract_block($template_album_list, 'footer');
$rows_separator = template_extract_block($template_album_list, 'row_separator');
$count = 0;
$columns = $CONFIG['album_list_cols'];
$column_width = ceil(100 / $columns);
$thumb_cell_width = $CONFIG['alb_list_thumb_size'] + 2;
starttable('100%');
if ($STATS_IN_ALB_LIST) {
$params = array('{STATISTICS}' => $statistics,
'{COLUMNS}' => $columns,
);
echo template_eval($stat_row, $params);
}
echo $header;
if (is_array($alb_list)) {
foreach($alb_list as $album) {
$count ++;
$params = array('{COL_WIDTH}' => $column_width,
'{ALBUM_TITLE}' => $album['album_title'],
'{THUMB_CELL_WIDTH}' => $thumb_cell_width,
'{ALB_LINK_TGT}' => "thumbnails.php?album={$album['aid']}",
'{ALB_LINK_PIC}' => $album['thumb_pic'],
'{ADMIN_MENU}' => $album['album_adm_menu'],
'{ALB_DESC}' => $album['album_desc'],
'{ALB_INFOS}' => $album['album_info'],
'{ALB_HITS}' => $album['alb_hits'],
);
$params = CPGPluginAPI::filter('theme_album_params', $params);
echo template_eval($album_cell, $params);
if ($count % $columns == 0 && $count < count($alb_list)) {
echo $rows_separator;
}
}
}
$params = array('{COL_WIDTH}' => $column_width,
'{SPACER}' => $thumb_cell_width
);
$empty_cell = template_eval($empty_cell, $params);
while ($count++ % $columns != 0) {
echo $empty_cell;
}
echo $footer;
// Tab display
$params = array('{COLUMNS}' => $columns,
'{TABS}' => $tabs,
);
echo template_eval($tabs_row, $params);
endtable();
echo $spacer;
}
/******************************************************************************
** Section <<<theme_display_album_list>>> - END
******************************************************************************/
/******************************************************************************
** Section <<<theme_display_album_list_cat>>> - START
******************************************************************************/
// Function to display first level Albums of a category
function theme_display_album_list_cat(&$alb_list, $nbAlb, $cat, $page, $total_pages)
{
global $CONFIG, $STATS_IN_ALB_LIST, $statistics, $template_tab_display, $template_album_list_cat, $lang_album_list;
if (!$CONFIG['first_level']) {
return;
}
$theme_alb_list_tab_tmpl = $template_tab_display;
$theme_alb_list_tab_tmpl['left_text'] = strtr($theme_alb_list_tab_tmpl['left_text'], array('{LEFT_TEXT}' => $lang_album_list['album_on_page']));
$theme_alb_list_tab_tmpl['page_link'] = strtr($theme_alb_list_tab_tmpl['page_link'], array('{LINK}' => 'index.php?cat=' . $cat . '&page=%d'));
$tabs = create_tabs($nbAlb, $page, $total_pages, $theme_alb_list_tab_tmpl);
// echo $template_album_list_cat;
$template_album_list_cat1 = $template_album_list_cat;
$album_cell = template_extract_block($template_album_list_cat1, 'c_album_cell');
$empty_cell = template_extract_block($template_album_list_cat1, 'c_empty_cell');
$tabs_row = template_extract_block($template_album_list_cat1, 'c_tabs');
$stat_row = template_extract_block($template_album_list_cat1, 'c_stat_row');
$spacer = template_extract_block($template_album_list_cat1, 'c_spacer');
$header = template_extract_block($template_album_list_cat1, 'c_header');
$footer = template_extract_block($template_album_list_cat1, 'c_footer');
$rows_separator = template_extract_block($template_album_list_cat1, 'c_row_separator');
$count = 0;
$columns = $CONFIG['album_list_cols'];
$column_width = ceil(100 / $columns);
$thumb_cell_width = $CONFIG['alb_list_thumb_size'] + 2;
starttable('99%'); // '100%' destroys the layout if $CONFIG['main_table_width'] is a pixel value
if ($STATS_IN_ALB_LIST) {
$params = array('{STATISTICS}' => $statistics,
'{COLUMNS}' => $columns,
);
echo template_eval($stat_row, $params);
}
echo $header;
if (is_array($alb_list)) {
foreach($alb_list as $album) {
$count ++;
$params = array('{COL_WIDTH}' => $column_width,
'{ALBUM_TITLE}' => $album['album_title'],
'{THUMB_CELL_WIDTH}' => $thumb_cell_width,
'{ALB_LINK_TGT}' => "thumbnails.php?album={$album['aid']}",
'{ALB_LINK_PIC}' => $album['thumb_pic'],
'{ADMIN_MENU}' => $album['album_adm_menu'],
'{ALB_DESC}' => $album['album_desc'],
'{ALB_INFOS}' => $album['album_info'],
'{ALB_HITS}' => $album['alb_hits'],
);
echo template_eval($album_cell, $params);
if ($count % $columns == 0 && $count < count($alb_list)) {
echo $rows_separator;
}
}
}
$params = array('{COL_WIDTH}' => $column_width,
'{SPACER}' => $thumb_cell_width
);
$empty_cell = template_eval($empty_cell, $params);
while ($count++ % $columns != 0) {
echo $empty_cell;
}
echo $footer;
// Tab display
$params = array('{COLUMNS}' => $columns,
'{TABS}' => $tabs,
);
echo template_eval($tabs_row, $params);
endtable();
echo $spacer;
}
/******************************************************************************
** Section <<<theme_display_album_list_cat>>> - END
******************************************************************************/
-
I'll have a look 8)
Thanks, your way seems a lot easier then copying the whole get_pic_url function ;)
Thanks Andre, what kind of mods need to be added do the display_albums sections?
With out a test gallery I can't be sure but looking at the code I would suggest exactly what Αndré had only with foreach($alb_list as $album) {
Find
foreach($alb_list as $album) {
and below, add
if (strpos($album['thumb_pic'], 'images/thumbs/thumb_nopic.png')) {
$album['thumb_pic'] = str_replace('images/thumbs/thumb_nopic.png', 'themes/your_theme_name/your_images_folder/your_logo.png', $album['thumb_pic']);
}
Not tested, as stated above. Let us know.
-
Yes it worked, thanks I now have the thumbnail without having to worry about upgrading, marking as solved.