forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: TNPihl on May 26, 2011, 09:16:14 pm

Title: URL to last uploaded photo
Post by: TNPihl on May 26, 2011, 09:16:14 pm
On the front page I have thumbnail of the last uploaded photo and I want a link to the same photo. But when I add the URL below it doesn't link to the last uploaded photo, but the second last.

/displayimage.php?album=lastup&cat=0&pos=1

What do I have to change so it will be the last photo.

Thanks.
Title: Re: URL to last uploaded photo
Post by: Αndré on May 27, 2011, 10:16:09 am
Try pos=0
Title: Re: URL to last uploaded photo
Post by: TNPihl on May 27, 2011, 06:00:08 pm
I have tried that, but it gives this error:

The selected album/file does not exist!
Title: Re: URL to last uploaded photo
Post by: Αndré on May 27, 2011, 06:05:26 pm
Please post a link to your gallery and any code that shows us how you display that thumbnail on your front page.
Title: Re: URL to last uploaded photo
Post by: TNPihl on May 27, 2011, 06:17:01 pm
The Gallery:
http://www.jimcarreyonline.com/images/

The Website with Latest Photo (thumbnail below Latest News)
http://www.jimcarreyonline.com/

Code:
<a href="/images/displayimage.php?album=lastup&cat=0&pos=0"><img src="<? echo $img ?>" alt="Latest Photo - Check out our image gallery" style="margin-top: 11px; opacity: 0.6; filter:alpha(opacity=60); -moz-opacity: 0.6; border: 1px solid #12522B;"></a>

(The thumbnail is working. It is the latest photo, but the URL to the page won't work)
Title: Re: URL to last uploaded photo
Post by: Αndré on May 27, 2011, 06:22:45 pm
Please also post the code that generates $img. It should be easy to extend that code so it fetches the picture id, which you need to build the correct link
Quote
displayimage.php?album=lastup&cat=0&pid=<picture_id>
Title: Re: URL to last uploaded photo
Post by: TNPihl on May 27, 2011, 06:25:56 pm
<?
function get_latest_image() {
   
   $query = 'select filepath, filename from cpg133_pictures where approved = "YES" order by pid desc limit 1';
   list($img, $sql) = sql_query($query, 'jco', 1,1);
   return ('/images/albums/'.$img['filepath'].'thumb_'.$img['filename']);
}
?>
Title: Re: URL to last uploaded photo
Post by: Αndré on May 27, 2011, 06:32:57 pm
Changing your function to
Code: [Select]
<?
function get_latest_image() {
   
   $query = 'select filepath, filename, pid from cpg133_pictures where approved = "YES" order by pid desc limit 1';
   list($img, $sql) = sql_query($query, 'jco', 1,1);
   return array('/images/albums/'.$img['filepath'].'thumb_'.$img['filename'], $img['pid']);
}
?>
should give you all needed data.
Title: Re: URL to last uploaded photo
Post by: TNPihl on May 27, 2011, 06:45:42 pm
I tried to paste it. It was not working.
Title: Re: URL to last uploaded photo
Post by: Αndré on May 27, 2011, 07:26:01 pm
Of course it won't work as-is, as I changed the return value. You have to adjust the rest of your code (which I don't know) accordingly. If I have to ask for every piece of code it isn't easy for me to help you, so again, please post the whole code if you need further assistance.
Title: Re: URL to last uploaded photo
Post by: TNPihl on May 27, 2011, 07:32:30 pm
      $img = get_latest_image();
                ?>
   
   <div style="float: right; width: 140px; height: 116px; background: url(/img/dot_bar_v.gif) repeat-y; text-align: center;">
   <img src="/img/hp/latest_photo.gif" width=80 height=5 alt="Latest Photo"><br>
   <a href="/images/displayimage.php?album=lastup&cat=0&pos=0"><img src="<? echo $img ?>" alt="Latest Photo - Check out our image gallery" style="margin-top: 11px; opacity: 0.6; filter:alpha(opacity=60); -moz-opacity: 0.6; border: 1px solid #12522B;"></a>
   </div>
</div>

<div style="clear: both;"></div>

<?
function get_latest_image() {
   
   $query = 'select filepath, filename from cpg133_pictures where approved = "YES" order by pid desc limit 1';
   list($img, $sql) = sql_query($query, 'jco', 1,1);
   return ('/images/albums/'.$img['filepath'].'thumb_'.$img['filename']);
}
?>
Title: Re: URL to last uploaded photo
Post by: Αndré on May 27, 2011, 07:58:01 pm
Try to change
Code: [Select]
<a href="/images/displayimage.php?album=lastup&cat=0&pos=0"><img src="<? echo $img ?>"to
Code: [Select]
<a href="/images/displayimage.php?album=lastup&cat=0&pid=<? echo $img[1] ?>"><img src="<? echo $img[0] ?>"
Title: Re: URL to last uploaded photo
Post by: TNPihl on May 27, 2011, 09:21:44 pm
It isn't working. It gives the same error. The thumbail is also not working.  :-\
Title: Re: URL to last uploaded photo
Post by: lurkalot on May 27, 2011, 09:46:37 pm
Can't you just use cpmfetch to display the image, and provide the link.  Set lastup, and one column, one row will give a single image which will be clickable.

Just an idea.  ;)