Display Thumbnails by Filename Display Thumbnails by Filename
 

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

Main Menu

Display Thumbnails by Filename

Started by Texas Kelly, February 02, 2008, 08:30:33 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Texas Kelly

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.)

Nibbler

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


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


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.

Texas Kelly

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! :)

Texas Kelly

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

Paste this into cpmfetch.php after function cpm_viewRandomMediaFrom
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
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);
}

Nibbler

Great. Thanks for posting your final code.