Advanced search  


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: Top-Rated Thumbnail as Category Thumbnail?  (Read 3000 times)

0 Members and 1 Guest are viewing this topic.

Shadow Wolf

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Top-Rated Thumbnail as Category Thumbnail?
« on: November 07, 2005, 11:45:37 pm »

It looks like we are able to set just one thumbnail to represent a category. Would it be possible to have it instead display the Top-Rated image in a category as the thumbnail instead?  I would think we could create a query for the rating, output the top rated one and then use that file name as the thumbnail... at least in theory.

Has someone done this already? If not what file or location would I have to look at to create something to go there?

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
Re: Top-Rated Thumbnail as Category Thumbnail?
« Reply #1 on: November 08, 2005, 08:10:27 am »

The code needed to accomplish what you're looking for hasn't been posted yet. You are right, you probably will have to run additional queries, which is not recommended if you have a busy site - the performance penalty could have quite an impact.

Shadow Wolf

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: Top-Rated Thumbnail as Category Thumbnail?
« Reply #2 on: November 08, 2005, 05:32:18 pm »

I have done some testing at least with query. It looks like I can get what I want by doing what I have listed below. I couldn't find what determined thumbnail names but I believe that is just thumb_(filename) based upon mkpcpg_pictures. I am not sure what I would look at codewise to see how the code for how it creates the actual main page when it displays the categories, maybe catmgr.php?

Depending on if it does a query then creates the HTML for the individual category/albums I would need to do more modifications. Since all the pictures are in *_pictures and it determines the albums by aid, I am not sure how to just get the top rated for a particular album. I can limit it to 1 but then an album would show other items not in that particular album. In the example I've just had it coded to pull from album 2 as a test.

Keep in mind that I am an amateur so the coding is probably not clean and not completely correct. I still don't know where the actual code for where it creates the HTML for it and the query that it does though.

Code: [Select]
$query = $DB->query( "SELECT aid, pic_rating, filepath, filename
                        FROM mkpcpg_pictures
                        WHERE aid=2
                        ORDER BY pic_rating
                        LIMIT 1");

while ( $row = $DB->fetch_row() ) {
       $album = $row['aid'];
       $rating = $row['pic_rating'];
$filepath = $row['filepath'];
$filename = $row['filename'];

$output ="
    <td align=\"center\" height=\"100%\" valign=\"middle\" class=\"tdblock\" style=\"padding: 5px;\">
      <img src=\"images/spacer.gif\" width=\"52\" height=\"1\" class=\"image\" style=\"margin-top: 0px; margin-bottom: 0px; border: none;\">
      <br />
      <a href=\"thumbnails.php?album=2\" class=\"albums\">
<img src=\"albums/{$filepath}/thumb_{$filename}\" class=\"image\" border=\"0\" alt=\"{$filename}\">
      <br /></a>
Pages: [1]   Go Up

Page created in 0.018 seconds with 19 queries.