URL to last uploaded photo URL to last uploaded photo
 

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]

Main Menu

URL to last uploaded photo

Started by TNPihl, May 26, 2011, 09:16:14 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TNPihl

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.

Αndré


TNPihl

I have tried that, but it gives this error:

The selected album/file does not exist!

Αndré

Please post a link to your gallery and any code that shows us how you display that thumbnail on your front page.

TNPihl

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)

Αndré

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
Quotedisplayimage.php?album=lastup&cat=0&pid=<picture_id>

TNPihl

<?
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']);
}
?>

Αndré

Changing your function to
<?
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.

TNPihl

I tried to paste it. It was not working.

Αndré

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.

TNPihl

      $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']);
}
?>

Αndré

Try to change
<a href="/images/displayimage.php?album=lastup&cat=0&pos=0"><img src="<? echo $img ?>"
to
<a href="/images/displayimage.php?album=lastup&cat=0&pid=<? echo $img[1] ?>"><img src="<? echo $img[0] ?>"

TNPihl

It isn't working. It gives the same error. The thumbail is also not working.  :-\

lurkalot

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.  ;)
Running SMF 2.1.4  / Tinyportal 3.0.1, bridged with Coppermine 1.6.25, plus cpmfetch 2.0.0