forum.coppermine-gallery.net

No Support => Modifications/Add-Ons/Hacks => Mods: Visuals => Topic started by: kousik on May 07, 2007, 06:59:51 am

Title: display last uploaded image fullsize in main page
Post by: kousik on May 07, 2007, 06:59:51 am
Hi.

I wanted to display the last uploaded image in full size in the first page. So I wrote up a few lines:


--- index.php~   Mon Apr 30 07:45:15 2007
+++ index.php   Mon Apr 30 19:04:23 2007
@@ -822,7 +822,14 @@ if (!$file) {
                         flush();
                         break;
 
+                    case 'lastimagefs':
+                        $pic_data = get_pic_data('lastup', $thumb_count, $album_name, -1, 1);
+                        $pic_url =  get_pic_url($pic_data[0], 'fullsize');
+                        theme_display_lastimage($pic_url);
+                        flush();
+                        break;
+
                     case 'lasthits':
                         display_thumbnails('lasthits', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                         flush();
--- include/themes.inc.php~   Mon Apr 30 07:25:17 2007
+++ include/themes.inc.php   Mon Apr 30 19:01:18 2007
@@ -1745,6 +1745,16 @@ function theme_display_album_list_cat(&$
 }
 }  //{THEMES}
 
+if (!function_exists('theme_display_lastimage')) {  //{THEMES}
+function theme_display_lastimage($picurl)
+{
+        starttable('100%', "Last uploaded image");
+        echo "<tr><td align=\"center\"><img src=\"$prefix" . "$picurl\" class=\"image\" border=\"0\" alt=\"\"></td></tr>";
+        endtable();
+}
+} //{THEMES}
+
+
 if (!function_exists('theme_display_thumbnails')) {  //{THEMES}
 function theme_display_thumbnails(&$thumb_list, $nbThumb, $album_name, $aid, $cat, $page, $total_pages, $sort_options, $display_tabs, $mode = 'thumb')
 {



So that adding "lastimagefs" as one of the option in "Config > Album List View > Contents of the main page" can display the last image uploaded fullsize.

This is a quick and dirty hack, and I am sure people who are a little bit familiar with coppermine can do a much better job.

regards
Kousik.
Title: Re: display last uploaded image fullsize in main page
Post by: Joachim Müller on May 07, 2007, 07:53:19 am
Thanks for your contribution. However, most users on this board are not capable to read and understand diffs, so I'd ask you to come up with instructions that are normally used on this board, with instructions like this:
Quote
Edit foobar.php
Find
Code: [Select]
fooand replace with
Code: [Select]
barThen find
Code: [Select]
blaand add after it (into a new line)
Code: [Select]
whatever
Thanks in advance.

Joachim
Title: Re: display last uploaded image fullsize in main page
Post by: SaWey on May 07, 2007, 01:57:45 pm
I took the liberty of creating the code:

In index.php

Find:

Code: [Select]
if (!$file) {
                         flush();
                         break;
 
                     case 'lasthits':
                         display_thumbnails('lasthits', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                         flush();

Change to:

Code: [Select]
if (!$file) {
                         flush();
                         break;
 
                     case 'lastimagefs':
                         $pic_url =  get_pic_url($pic_data[0], 'fullsize');
                         theme_display_lastimage($pic_url);
                         flush();
                         break;
 
                     case 'lasthits':
                         display_thumbnails('lasthits', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                         flush();


In include/themes.inc.php:

Find:

Code: [Select]
function theme_display_album_list_cat(&$
 }
 }  //{THEMES}
 
 if (!function_exists('theme_display_thumbnails')) {  //{THEMES}
 function theme_display_thumbnails(&$thumb_list, $nbThumb, $album_name, $aid, $cat, $page, $total_pages, $sort_options, $display_tabs, $mode = 'thumb')
 {

Change to:

Code: [Select]
function theme_display_album_list_cat(&$
 }
 }  //{THEMES}
 
 if (!function_exists('theme_display_lastimage')) {  //{THEMES}
 function theme_display_lastimage($picurl)
 {
         starttable('100%', "Last uploaded image");
         echo "<tr><td align=\"center\"><img src=\"$prefix" . "$picurl\" class=\"image\" border=\"0\" alt=\"\"></td></tr>";
         endtable();
 }
 } //{THEMES}
 
 
 if (!function_exists('theme_display_thumbnails')) {  //{THEMES}
 function theme_display_thumbnails(&$thumb_list, $nbThumb, $album_name, $aid, $cat, $page, $total_pages, $sort_options, $display_tabs, $mode = 'thumb')
 {
Title: Re: display last uploaded image fullsize in main page
Post by: kousik on May 07, 2007, 03:05:28 pm
As per admin suggestion, here goes the modification in more legible format:

In your installation directory, open the file index.php and try locating the following code somewhere under // Main code:
Code: [Select]
                    case 'toprated':
                        display_thumbnails('toprated', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                        flush();
                        break;

                    case 'lastcom':
                        display_thumbnails('lastcom', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                        flush();
                        break;

Now, in between any two break; and a new case 'something', take 'lastcom' for example, insert the following code:

Code: [Select]
                    case 'lastimagefs':
                        $pic_data = get_pic_data('lastup', $thumb_count, $album_name, -1, 1);
                        $pic_url =  get_pic_url($pic_data[0], 'fullsize');
                        theme_display_lastimage($pic_url);
                        flush();
                        break;

I hope you got the pattern ...

Then open up include/themes.inc.php and add the following code at the bottom:

Code: [Select]
if (!function_exists('theme_display_lastimage')) {  //{THEMES}
function theme_display_lastimage($picurl)
{
        starttable('100%', "Last uploaded image");
        echo "<tr><td align=\"center\"><img src=\"$prefix" . "$picurl\" class=\"image\" border=\"0\" alt=\"\"></td></tr>";
        endtable();
}
} //{THEMES}

Now the groundwork is ready, get to your gallery in admin mode, go to "Config > Album List view". In the box "The content of the main page", there should be some / separated  values. Insert lastimagefs wherever you want the last uploaded image to appear in full-size.

An example can be seen in my gallery at http://www.employees.org/~kousik/photography/

Thanks,
Kousik
Title: Re: display last uploaded image fullsize in main page
Post by: mentalist3d on November 01, 2007, 11:39:56 am
Thanks for the mod, it works really well and was something I had been looking for a while. Thanks :-)
Title: Re: display last uploaded image fullsize in main page
Post by: mentalist3d on November 27, 2007, 01:58:07 pm
Hi, I'm wondering if there is any edits to the script that will allow the last uploaded image to include the details of who uploaded the image (ie - Last uploaded image by USERNAME) with a link back to their profile?

Any help or advice is always welcome :-)

Thanks - James

http://art.concepts.org.uk
Title: Re: display last uploaded image fullsize in main page
Post by: bbm on July 07, 2009, 01:39:22 pm
Nice mod ! Would it be possible to have this done with random-pic instead of lastup ?