TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 316
  • Total: 316

Random photos from coppermine

Started by carver, September 22, 2005, 01:32:19 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

RoarinRow

#160
This code works for me just fine as far as displaying the pictures and no errors in the log. 

echo "<CENTER>";
chdir("../gallery/cpmfetch/");
include "cpmfetch.php";                   
$objCpm = new cpm();
$objCpm->cpm_viewRandomMedia(1,6,array("imageheight" => "75"));
$objCpm->cpm_close();
chdir("../../");
echo '<a href="http://www.mysite.com/forum/index.php?action=forum">View Gallery</a>';
echo "</center>";


However, I get 16 debug errors half related to TP and the other to SMF.  I am using the 'Errors On Top' modification, which shows me that information.  Anyone  have this mod who sees this same 'debug' message?  Any harm if I ignore it   :2funny:

Otherwise, it pulls in the pictures just fine.   :up:

I'm on CPG 1.4.12 with CPMfetch 2.0.0 on SMF 1.1.3 TP .0983

SMF 2.0 RC3
TP 1.0 beta 5-1
Wordpress 3.0

chep

#161
Not sure if someone already did this example...

I always want to click on the random coppermine thumbnail image which I generated to see the full size image.

Here is my code which I tweaked... jpg files only..... and put inside a left or right php block. It may be optimal to include the sql connection info from an external file instead; for security reasons.. but I left it all here to see.



$result1 = @mysql_connect('localhost', 'username', 'PASSWORD');

$result1 = mysql_query("SELECT filename,filepath from cpg1_pictures where filename like \"%.jpg\" or (filename like \"%.jpeg\") ORDER BY RAND() LIMIT 1") ;
$row1 = mysql_fetch_array($result1);
mysql_free_result($result1);
$filename1 = 'thumb_' . $row1['filename'];

echo '<div align="center"><a href="http://somewebsite.com/cpg/albums/' , $row1['filepath'] , $row1['filename'] , '" target="new"><img src="http://somewebsite.com/cpg/albums/' , $row1['filepath'] , $filename1 , '" alt="Random Photo"/></a></div>';

sabyre

After reading this thread and some others like it I thought I would share what I learned. CPMFetch is great; unfortunately the way in which CPG integrates with SMF/TP (iframe) it is difficult to get the thumbnail to link properly.

As an alternative I have seen people ask how to stop the thumbnail from linking entirely.

Here is how you do that:



echo '<center>';  include_once "./gallery/cpmfetch/cpmfetch.php";
  $options = array( 'imagelink' => 'none' );
  $objCpm = new cpm("./gallery/cpmfetch/cpmfetch_config.php");
  $objCpm->cpm_viewRandomMedia(1,1,$options);
  $objCpm->cpm_close();
echo '</center>';



Note line 2 and line 4. This is the code within your block.

I personally have setup for my off-road site, thumbnail link off and a link to my gallery under the thumb.

Here is the code I used for that:



echo '<center>';  include_once "./gallery/cpmfetch/cpmfetch.php";
  $options = array( 'imagelink' => 'none' ); 
  $objCpm = new cpm("./gallery/cpmfetch/cpmfetch_config.php");
  $objCpm->cpm_viewRandomMedia(1,1,$options);
  $objCpm->cpm_close();
echo '<a href="http://www.maine4x4.org/community/index.php?action=Coppermine">View Gallery</a>';
echo '</center>';



Using the linktemplate option you can specifically or dynamically set the output link URL. More information can be found on this in the documentation.

The author of this script is great and included a ton of options and features. All of which you can find in the extensive documentation that he provides.

Here

More specifically information on the $options call can be found:

Here

I hope this has helped some!

Stern

Quote from: RoarinRow on August 22, 2007, 01:44:36 AM
This code works for me just fine as far as displaying the pictures and no errors in the log. 

echo "<CENTER>";
chdir("../gallery/cpmfetch/");
include "cpmfetch.php";                  
$objCpm = new cpm();
$objCpm->cpm_viewRandomMedia(1,6,array("imageheight" => "75"));
$objCpm->cpm_close();
chdir("../../");
echo '<a href="http://www.mysite.com/forum/index.php?action=forum">View Gallery</a>';
echo "</center>";


However, I get 16 debug errors half related to TP and the other to SMF.  I am using the 'Errors On Top' modification, which shows me that information.  Anyone  have this mod who sees this same 'debug' message?  Any harm if I ignore it   :2funny:

Otherwise, it pulls in the pictures just fine.   :up:

I'm on CPG 1.4.12 with CPMfetch 2.0.0 on SMF 1.1.3 TP .0983

Thank you, RoarinRow! only this code is worked on all my bundles TP(.0983) + SMF(1.1.4) + CPG(1.4.10/1.4.14) with CPMfetch 2.0.0...

I used Mod 'Errors On Top' one year ago during a few days, then I removed it - one half of meter 'debug' messages they were not greatly pleased to me (sorry my bad english ;-)).

JustOneOldMan

Agree with Stern.  Thanks RoarinRow, worked perfect and was exactly what I was looking for.

SMF 114, TP 983, CPG 114

/JOOM

lurkalot

Quote from: RoarinRow on August 22, 2007, 01:44:36 AM
This code works for me just fine as far as displaying the pictures and no errors in the log. 

echo "<CENTER>";
chdir("../gallery/cpmfetch/");
include "cpmfetch.php";                  
$objCpm = new cpm();
$objCpm->cpm_viewRandomMedia(1,6,array("imageheight" => "75"));
$objCpm->cpm_close();
chdir("../../");
echo '<a href="http://www.mysite.com/forum/index.php?action=forum">View Gallery</a>';
echo "</center>";


However, I get 16 debug errors half related to TP and the other to SMF.  I am using the 'Errors On Top' modification, which shows me that information.  Anyone  have this mod who sees this same 'debug' message?  Any harm if I ignore it   :2funny:

Otherwise, it pulls in the pictures just fine.   :up:

I'm on CPG 1.4.12 with CPMfetch 2.0.0 on SMF 1.1.3 TP .0983

This one works fine for me too.   Using smf 1.1.4, Tinyportal 0.9.8, Coppermine 1.4.13 and Coppermine fetch 2.0.0

I've put it in a php article.  Thanks for sharing it.  See here. http://cameracraniums.com

Any way of adding this to an existing article at the top of it, and keeping my welcome message etc intact?   I'm very new to this sort of stuff and haven't a clue about php / html etc.  Also how do I get it to show the latest uploaded pics?

kylemj

This displays a random images and then the latest image @ 120px

[random]
[latest]
[View Gallery]

echo "<CENTER>";
chdir("../gallery/cpmfetch/");
include "cpmfetch.php";                   
$objCpm = new cpm();
$objCpm->cpm_viewRandomMedia(1,1,array("imageheight" => "120"));
$objCpm->cpm_close();
$objCpm = new cpm();
$objCpm->cpm_viewLastAddedMedia(1,1,array("imageheight" => "120"));
$objCpm->cpm_close();
chdir("../../");
echo '<a href="http://www.jordan.thecelebvenue.com/gallery">View Gallery</a>';
echo "</center>";

RoarinRow

Cool, I'm glad it worked for you all.  Sorry for the late response, I've been super super busy at work   :o  Plus I recently went through a server move    :uglystupid2:

SMF 2.0 RC3
TP 1.0 beta 5-1
Wordpress 3.0

forummaker

Here's something odd. When I have a "Copperminefetch" block and a "SMF Gallery Random Picture" block on the front page at the same time the SMF GRP block does not display, and displays this error:
MySQL error:Can't connect to local MySQL server through socket '/usr/local/mysql-5.0/data/mysql.sock' (2)
The error goes away when I remove the Copperminefetch block. I'd like to have both boxes on the page at the same time, but what do I need to do? I posted this same question on the SMF GRP block snippit area and was recommended to ask here. Thanks in advance for any help.
Here's the link. www.remedydog.com

G6Cad

Have you edit the settings in your cpmfetch so they point to the correct location on your server and path ?

This website is proudly hosted on Crocweb Cloud Website Hosting.