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: Display Thumbnails by Filename  (Read 5814 times)

0 Members and 1 Guest are viewing this topic.

Texas Kelly

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Display Thumbnails by Filename
« on: February 02, 2008, 08:30:33 pm »

Background: I'm the technical administrator for a Survivor fansite. We're in the business of spoiler analysis from vidcaps of episodes, previews, and the like. I set up a Coppermine gallery to facilitate the uploading and organization of our vidcaps. With a lot of work and elbow-grease, I've also managed to use cpmFetch to allow our users to post thumbnails from Coppermine in posts on our vBulletin forums, using a BBCode. (Not ready to go public with that one yet, because I'm still testing/refining it, but it works wonderfully.)

Problem: When my users post vidcaps, there's a specific order to them (based on the order they appear in the source material that they come from). Neither of the methods of pulling thumbnails in cpmFetch (random, last uploaded) is all that conducive to getting the thumbnails to display in the order we'd like them to. I'm telling my users to upload in reverse order with a cockamamie methodology, and I want to make it easier for them.

Is there a way in the current version of cpmFetch to get the thumbnails to display in an order based on filename? (For example, if the pictures in an album were named Cap001, Cap004, Cap003, Cap007, Cap002, etc.; cpmFetch would display the thumbnails in order: Cap001, Cap002, Cap003, Cap004, etc.) If there isn't a way, currently, how difficult would it be to add a function like cpm_viewMediaFromByFilename()?

I've scoured the documentation and searched these forums fruitlessly. Please help!

Using: I'm using the current stable version of cpmFetch (2.0.0) and version 1.4.15 of Coppermine. (I'm using GD for thumbnails, so no need to upgrade to 1.4.16.)
« Last Edit: February 02, 2008, 11:20:38 pm by Nibbler »
Logged

Nibbler

  • Guest
Re: Display Thumbnails by Filename
« Reply #1 on: February 02, 2008, 10:26:59 pm »

Should be easy enough. Take this one as an example:

Code: [Select]
function cpm_viewTopRatedMediaFrom ($source, $rows, $columns, $options="") {
$this->loadOptions($options);

$resultset = $this->getTopRatedMediaFrom ($source, $rows * $columns);
$this->addDescriptionsToResultSet($resultset);

$retval = "";
switch ($this->returntype) {
case ('resultset'):
$retval = $resultset;
break;
case ('html'):
$retval = $this->createTable($resultset,$rows,$columns);
break;
case ('print'):
default:
print $this->createTable($resultset,$rows,$columns);
}

$this->clearOptions();
return ($retval);

}

copy it, rename the copy, then do likewise for the function it calls

Code: [Select]
function getTopRatedMediaFrom ($source, $count = 1) {
$resultset = array();
if (is_numeric($count)) {

$sourceSql = $this->makeSourceSql($source);

if ($sourceSql != "") $sourceSql = " AND " . $sourceSql;

$sqlcode = "SELECT {$this->sqlPostSelect} " . $this->sqlSelect . " FROM "
. $this->sqlTableSelect
. " WHERE 1 "
. $this->sqlUserDataLink
. $this->filetypefilter ." AND p.approved='YES' "
. $sourceSql . " {$this->privacyfilter} "
. " ORDER BY p.pic_rating DESC LIMIT 0,$count";

$resultset = $this->dbExecuteSql($sqlcode);
$this->addPathInfo($resultset);
}
elseif ($this->cfg['cfDebugMode'] == 'true'){
debugPrint("Non numeric count submitted");
}

return ($resultset);
}

Change the 'order by' to be by filename ascending instead of rating descending.

I don't have cpmfetch installed so I can't give you copy/paste code.
Logged

Texas Kelly

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Re: Display Thumbnails by Filename
« Reply #2 on: February 02, 2008, 11:07:55 pm »

That's what I tried before I posted, and it didn't work... but when I tried it again with the code snippets you provided, it worked fine! Puzzling... ???

Anyways, thanks for your help! :)
Logged

Texas Kelly

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Re: Display Thumbnails by Filename
« Reply #3 on: February 02, 2008, 11:11:46 pm »

Here's the snippets of code I used if anyone else wants to do this:

Paste this into cpmfetch.php after function cpm_viewRandomMediaFrom
Code: [Select]
function cpm_viewMediaFromByFilename ($source, $rows, $columns, $options="") {
$this->loadOptions($options);

$resultset = $this->getMediaFromByFilename ($source, $rows * $columns);
$this->addDescriptionsToResultSet($resultset);

$retval = "";
switch ($this->returntype) {
case ('resultset'):
$retval = $resultset;
break;
case ('html'):
$retval = $this->createTable($resultset,$rows,$columns);
break;
case ('print'):
default:
print $this->createTable($resultset,$rows,$columns);
}

$this->clearOptions();
return ($retval);

}

Paste this into cpmfetch_dao.php after function getMediaAddedSince
Code: [Select]
function getMediaFromByFilename ($source, $count = 1) {
$resultset = array();
if (is_numeric($count)) {

$sourceSql = $this->makeSourceSql($source);

if ($sourceSql != "") $sourceSql = " AND " . $sourceSql;

$sqlcode = "SELECT {$this->sqlPostSelect} " . $this->sqlSelect . " FROM "
. $this->sqlTableSelect
. " WHERE 1 "
. $this->sqlUserDataLink
. $this->filetypefilter ." AND p.approved='YES' "
. $sourceSql . " {$this->privacyfilter} "
. " ORDER BY p.filename ASC LIMIT 0,$count";

$resultset = $this->dbExecuteSql($sqlcode);
$this->addPathInfo($resultset);
}
elseif ($this->cfg['cfDebugMode'] == 'true'){
debugPrint("Non numeric count submitted");
}

return ($resultset);
}
Logged

Nibbler

  • Guest
Re: Display Thumbnails by Filename
« Reply #4 on: February 02, 2008, 11:20:56 pm »

Great. Thanks for posting your final code.
Logged
Pages: [1]   Go Up
 

Page created in 0.018 seconds with 19 queries.