analogue thumb call for 'filename' in cpg1410_pictures table analogue thumb call for 'filename' in cpg1410_pictures table
 

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

analogue thumb call for 'filename' in cpg1410_pictures table

Started by wipqozn1, May 06, 2007, 03:11:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wipqozn1

How could I get a name of thumbnail using database query? When I want get a file name I do like this (part of one of my files):

    SELECT p.pid, aid, filepath, filename, owner_name, owner_id
//bla bla blah

  $img = "<img src=\"http://url/albums/userpics/normal_{$picture['filename']}\"  border=\"0\">";   


Now I want sth like this:

  $img = "<img src=\"http://url/albums/userpics/<HERE THUMB NAME FOR RECENT IMAGE\"  border=\"0\">"; 

There is no such row in database like "thumb" so I've stuck here...

Nibbler


wipqozn1

Yes, usually it would be like You said but...

I've got different situation here. I've got .swf files and .jpg thumbs. So if I'do like this for file FILE.swf:

$img = "<img src=\"http://url/albums/userpics/thumb_{$picture['filename']}\"  border=\"0\">";

It will try to show file thumb called thumb_FILE.swf which does not exist (thumb_FILE.jpg exists instead). So it's not so simple :-)

Nibbler

Then you'd need to use the built-in function, get_pic_url() like this

$thumbnail = get_pic_url($row, 'thumb');

where $row is the row from the database for that file. If you are outside Coppermine then you'd need to take a look at the function and build you own version.

wipqozn1

Is it mean that it's can't be automatic or I get it wrong?

'cause if I'd like to use this function this way:

  $thumbnail = get_pic_url($row, 'thumb');
  $img = "<img src=\"".$thumbnail."\"  border=\"0\">";


then I should give by hand exact name/number of row each time, right (and I'm supposed to pass the row by reference as I see)? And I should create a row for each file?

Regardless of if I'm right or not above, could You show me an example of using this function according to my case?

Nibbler

$row is what you are calling $picture in your code above.


$row = mysql_fetch_assoc($result);
$thumbnail = get_pic_url($row, 'thumb');


You don't need to to anything special to pass it by reference; the function does that itself.

wipqozn1

Okay, I understand now. Anyway, it gives me an error:

Fatal error: Call to undefined function: cpg_get_type() in server_path/include/functions.inc.php on line 1927

It's line inside get_pic_url() definition:

$mime_content = cpg_get_type($pic_row['filename']);

cpg_get_type function is defined in /include/media.functions.inc.php - shouldn't this function be global? (I'm a cpp coder, so maybe it's just my cpp deviation)

Nibbler

You'd need to include that file before you call the function.

wipqozn1


Nibbler

I said at the start if you are outside Coppermine you'd need to make your own function. It's not designed to be used form outside Coppermine.

wipqozn1

But I use this function inside Coppermine, not outside.

Nibbler

You can't be. If you were then you would not need to include/media.functions.inc.php since it is already included.

wipqozn1

I've just downloaded cpg once again to check if I didn't mess up the code - but media.functions.inc.php isn't included in functions.inc.php by default.

I use this function in showweekpic.php file (potd plugin) - 'cause without further modifications in this file it brings me those d**n blank pages.

Nibbler

Right, so you are not in Coppermine.

media.functions.inc.php is included by init.inc.php - it won't work if you include it from somewhere else becuase it needs to refer to things that have been setup in init.inc.php. You can either find what it needs and copy them into your script or make a stripped down version of the function yourself.

wipqozn1

Can You do it for me as a 'Paid help'? (I don't start new thread yet in that sub-forum). My PHP programmer has much to do right now and he won't be able to do it as fast as I need  (since he'd analyse a lot of code).

Nibbler

No, but maybe someone else will if you post the request.

Joachim Müller

@wipqozn1: do you want this thread moved to the paid help sub-board.

wipqozn1

No thanks - I've starded a new thread there where I also put a link to this one :-)