Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: String ? help needed  (Read 5388 times)

0 Members and 1 Guest are viewing this topic.

rphMedia

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 515
  • ***muvipix.com***
    • muvipix - Music | Video | Pictures
String ? help needed
« on: November 19, 2004, 12:37:54 pm »

In this thread here (solved - didn't want to reopen), I have the output running smooth, even got a random thing going on, question:

For the output, how can I append the 'filename' with normal_ or even the thumb_ prefix (for future reference). I realize it's a string type thing, but I've tried many ways and I screw up the array function when I do it. I can't find anything in the database that has this reference, so it's beyond me how you guys do that in displayimage. Thanks for all the help so far.  I'm just about finished with this little project.

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: String ? help needed
« Reply #1 on: November 19, 2004, 01:33:02 pm »

You can use $CONFIG['normal_pfx'] for the prefix of the intermediate sized pic and $CONFIG['thumb_pfx'] for the thumbnail prefix.

Joachim
Logged

rphMedia

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 515
  • ***muvipix.com***
    • muvipix - Music | Video | Pictures
Re: String ? help needed
« Reply #2 on: November 19, 2004, 01:42:21 pm »

I cannot believe that these answers are so simple in nature, sorry!  But I AM learning tons from these tid-bits. It's coming together....

And I'm sure you can tell where I'm going with this  ;D

Thanks much Joachim [solved]

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: String ? help needed
« Reply #3 on: November 19, 2004, 01:48:24 pm »

to find out about the $CONFIG array, use phpMyAdmin to browse the table cpgXXX_config in your coppermine database - it has all most configuration vars you will need. Another option is to take a look at the file sql/basic.sql with a plain text editor. Either way will show the same results. At the moment it's a bit chaotic though - we have no dev decomentation yet that covers such things for mod authors - you're welcome to post such questions. Glad the advice worked for you. You're in the process of understanding the coppermine app - isn't that fun to discover how it works? For me it surely was (and still is, as I consider myself still a learner).

Joachim
Logged

rphMedia

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 515
  • ***muvipix.com***
    • muvipix - Music | Video | Pictures
Re: String ? help needed
« Reply #4 on: November 19, 2004, 02:02:07 pm »

Ahh, the reason I couldn't find it was because my phpMyAdmin had 2 other pages of variables in the config table.  More learning.

Yes, this is an adventure and it's consuming me right now.  Your tips are invaluable.

I just realized another problem.....(I think).  Is it true that if coppermine sees that an image doesn't need a normal_ prefix (width/height is less than normal_), it doesn't add/create the normal_ image?  I only found that because I had a blank image looking for normal_. 

I think I need an if statement, but I'll tackle that one.

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: String ? help needed
« Reply #5 on: November 19, 2004, 02:18:21 pm »

that's correct: to save precious webspace, intermediate sized files are only being created if the full size (original) pic is larger (in terms of dimension) than the size for intermediate sized files is set up in coppermine config. It'd be a waste of resources if the full-sized pic and the intermediate sized pic where the same size, of the intermediate sized file were even larger than the full sized one.

I recommend to take a look into include/functions.inc.php - most functions you will need already exist there, you can just call them instead of creating your own functions from scratch...

Joachim
Logged

rphMedia

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 515
  • ***muvipix.com***
    • muvipix - Music | Video | Pictures
Re: String ? help needed
« Reply #6 on: November 21, 2004, 03:59:11 pm »

Joachim (or whoever wants to help) -

I'm real close here with this hack.  It's going to be nice as there's really no limit as to what it's going to be able to do (pretty customizable). I'm stuck implementing an 'if' statement for this particular setup. I've manged to convert this code to render xml and in turn my flash file reads it.

Again, this particular setup takes the last 10 uploaded images and renders in a/the slideshow. I've also managed to grab the titles and am captioning on the show.  Anyway, as you said, sometimes the normal_ prefix is not added (I understand) - How can I make sure that all images have this normal_ prefix? I have it commented where I though it would work, but can't get it.


<?
define('IN_COPPERMINE'true);
require(
'include/init.inc.php');
$xml .= '<?xml version="1.0" encoding="UTF-8" ?>';
$xml .= '<slideshow><settings><image_folder></image_folder><time>3</time><fade>1</fade><repeat>true</repeat><captions>true</captions></settings><images>';
$result mysql_query("SELECT a.pid, a.aid, a.filename, a.filepath, a.title, a.caption, b.title atitle from {$CONFIG['TABLE_PICTURES']} a, {$CONFIG['TABLE_ALBUMS']} b where a.aid = b.aid order by a.aid, a.pid desc LIMIT 10");
global 
$xml;
if (!
mysql_num_rows($result)) cpg_die(ERROR$lang_errors['non_exist_ap']);
$p_aid = -;
   while (
$row mysql_fetch_array($result)) 
        { 
                if (
$row[aid] != $p_aid) {  
	
               
// if ($CONFIG('normal_pfx'))  --- Something along this line.
}
	
               
$xml .= "<image><file>$CONFIG[fullpath]$row[filepath]$CONFIG[normal_pfx]$row[filename]</file><caption><![CDATA[$row[title]]]></caption></image>";
$p_aid $row[aid] ;
}    
$xml .= '</images></slideshow>';
echo 
$xml;
?>


...or if you know a better way to handle it and several other situations (say we wanted to pull out the full size images, etc...).  Thanks.

Nibbler

  • Guest
Re: String ? help needed
« Reply #7 on: November 21, 2004, 08:20:37 pm »

You could do a file_exists() to see if the normal_ version exists or you could use a dimension check:

Code: [Select]
if (max($row['pwidth'], $row['pheight']) > $CONFIG['picture_width'])
{
// we have a normal version
} else {
// small pic - no normal version exists
}

where $row is a row from the pictures table for that picture.
Logged

rphMedia

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 515
  • ***muvipix.com***
    • muvipix - Music | Video | Pictures
Re: String ? help needed
« Reply #8 on: November 21, 2004, 09:37:35 pm »

Thanks Nibbler, but that doesn't seem to work.  I thought it would.  Here's what I did (didn't throw in the else yet, just experimenting)

<?
define('IN_COPPERMINE', true);
require('include/init.inc.php');
$xml .= '<?xml version="1.0" encoding="UTF-8" ?>';
$xml .= '<slideshow><settings><image_folder></image_folder><time>3</time><fade>1</fade><repeat>true</repeat><captions>true</captions></settings><images>';
$result = mysql_query("SELECT a.pid, a.aid, a.filename, a.filepath, a.title, a.caption, a.pwidth, a.pheight, b.title atitle from {$CONFIG['TABLE_PICTURES']} a, {$CONFIG['TABLE_ALBUMS']} b where a.aid = b.aid order by a.aid, a.pid desc LIMIT 10");
global $xml;
if (!mysql_num_rows($result)) cpg_die(ERROR, $lang_errors['non_exist_ap']);
$p_aid = -1 ;
while ($row = mysql_fetch_array($result)) 
        { 
                if ($row[aid] != $p_aid && (max($row['pwidth'], $row['pheight']) > $CONFIG['picture_width'])) {
}
	
               $xml .= "<image><file>$CONFIG[fullpath]$row[filepath]$CONFIG[normal_pfx]$row[filename]</file><caption><![CDATA[$row[title]]]></caption></image>";
	
               $p_aid = $row[aid] ;
}    
$xml .= '</images></slideshow>';
echo $xml;
?>


I have a small jpg in there that is definitely less than picture_width and it's still adding the normal_ prefix to it (which is blank obviously). Is it in the wrong place?

Nibbler

  • Guest
Re: String ? help needed
« Reply #9 on: November 21, 2004, 09:43:19 pm »

You have nothing in the if condition.

Code: [Select]
if (something)
{
do something
}

You have nothing happening with the if condition and always adding the normal prefix. Only add the $CONFIG[normal_pfx] if that condition is true.
Logged

rphMedia

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 515
  • ***muvipix.com***
    • muvipix - Music | Video | Pictures
Re: String ? help needed
« Reply #10 on: November 22, 2004, 02:09:02 pm »

Thanks Nibbler, [solved].  Mod/Hack forthcoming.
Pages: [1]   Go Up
 

Page created in 0.025 seconds with 20 queries.