Added CpmFetch to WordPress blog

I have added CPM Fetch to my blog. The author, vuud, describes CpmFetch as:

…a PHP object that allows you to easily display random or latest images from your coppermine gallery on external php and html pages… You can draw images (random or otherwise) from the entire gallery, a specific category or a single album.

I’m using CpmFetch to display a random image from my gallery. You can see it in the sidebar.

The code to put into the theme’s sidebar file is:

	<li>Random Photo</li>
		<div align="center">
		<?php
		include("$cpmfetch_path");
		$objCpm = new cpm("$cpm");
		$options = array( 'subtitle' => '<a href="http://takethu.com/displayimage.php?pos=-%i">Details</a><br/>
										Album: %a<br/>
										<i>%t</i>
										',
							'imagelink' => 'large',
							"linkstyle" => 'highslide" onclick="return hs.expand(this)" onmouseover="self.status='Click to enlarge thumbnail'; return true;',
						);
		$objCpm->cpm_viewRandomMedia(1,1, $options);

}
		?>

		</div>

I defined the cpm variables earlier in my file based on if it is the local or remote installation. You can either create and define the variables with your settings or just replace the variables with your own settings.

The code is written to work with Highslide JS so you would need to tweak the code if you don’t want to use it.

5 thoughts on “Added CpmFetch to WordPress blog”

  1. Hi Thu :)

    I was searching for a way to use cpmfetch in multiple post on my own blog and came upon this post on your blog.

    You say you defined the cpm variables earlier in your file. I am not a coder but i guess this include(“$cpmfetch_path”); call to the follwing code “include_once “./cpg/cpmfetch/cpmfetch.php”; // Line 1
    $objCpm = new cpm(“./cpg/cpmfetch/cpmfetch_config.php”); // Line 2 ”

    Using this method is it possible to use cpmfetch in multiple posts or not ? And would you be willing to share how you have done it ?

    Cheers
    Hein

  2. Hey Hein,

    I’m only using cpmfetch for the Random Photo in my sidebar. I’m not sure how cpmfetch would be used in multiple posts, but just about anything is possible. Could you please provide more insight into what you want to do?

  3. Okay, so you want to put in code for each post, in the content of the entry, rather than in the source code of the page, right? I went to look at the documentation but it seems that there are 4 versions: http://cpmfetch.fistfullofcode.com/docs/index.php

    Which one are you using? I am pretty sure I have seen an example of multiple calls to cpmfetch on one page. The only thing is you wouldn’t be able to use PHP in your post to call it. Maybe it’s possible to use cpmfetch with html. If not, there might be a WordPress plugin that will parse PHP code within posts.

    Unfortunately, that’s the limit to which I can be of assistance. Hopefully this works out for you.

  4. Thanks for the advice Thu.. i think i can work with that.

    Your code has this piece “include(“$cpmfetch_path”);” , how did you define the cpm variables earlier in your file ?

    Hein

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>