Advanced search  

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

Pages: [1]   Go Down

Author Topic: URL to last uploaded photo  (Read 4624 times)

0 Members and 1 Guest are viewing this topic.

TNPihl

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
URL to last uploaded photo
« 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.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: URL to last uploaded photo
« Reply #1 on: May 27, 2011, 10:16:09 am »

Try pos=0
Logged

TNPihl

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: URL to last uploaded photo
« Reply #2 on: May 27, 2011, 06:00:08 pm »

I have tried that, but it gives this error:

The selected album/file does not exist!
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: URL to last uploaded photo
« Reply #3 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.
Logged

TNPihl

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: URL to last uploaded photo
« Reply #4 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)
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: URL to last uploaded photo
« Reply #5 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>
Logged

TNPihl

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: URL to last uploaded photo
« Reply #6 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']);
}
?>
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: URL to last uploaded photo
« Reply #7 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.
Logged

TNPihl

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: URL to last uploaded photo
« Reply #8 on: May 27, 2011, 06:45:42 pm »

I tried to paste it. It was not working.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: URL to last uploaded photo
« Reply #9 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.
Logged

TNPihl

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: URL to last uploaded photo
« Reply #10 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']);
}
?>
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: URL to last uploaded photo
« Reply #11 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] ?>"
Logged

TNPihl

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: URL to last uploaded photo
« Reply #12 on: May 27, 2011, 09:21:44 pm »

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

lurkalot

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 949
  • +Tinyportal Support team.
Re: URL to last uploaded photo
« Reply #13 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.  ;)
Logged
Running SMF 2.1.4  / Tinyportal 3.0.0, bridged with Coppermine 1.6.25, plus cpmfetch 2.0.0
Pages: [1]   Go Up
 

Page created in 0.023 seconds with 20 queries.