forum.coppermine-gallery.net
Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: wipqozn1 on May 06, 2007, 03:11:38 pm
-
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...
-
Same as you have but use thumb_ instead of normal_
-
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 :-)
-
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.
-
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?
-
$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.
-
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)
-
You'd need to include that file before you call the function.
-
So i did... now it gives me a mysql error, take a look: http://gryz.pl
-
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.
-
But I use this function inside Coppermine, not outside.
-
You can't be. If you were then you would not need to include/media.functions.inc.php since it is already included.
-
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.
-
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.
-
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).
-
No, but maybe someone else will if you post the request.
-
@wipqozn1: do you want this thread moved to the paid help sub-board.
-
No thanks - I've starded a new thread there where I also put a link to this one :-)
-
Done: http://forum.coppermine-gallery.net/index.php?topic=43643.0