coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 cpmFetch by vuud => Topic started by: Zarzal on July 05, 2007, 09:52:31 AM

Title: How I use cpmfetch V2.x inside img src ?
Post by: Zarzal on July 05, 2007, 09:52:31 AM
Hello,
I use cpmfetch long time. Yesterday I change my webserver and by this way I have to upgrade something. Last version I work with was 1.9x and now I change to V2.0 release.
On my old days I use cpmfetch to display a randon image on my homepage (http://www.biker-reise.de/galerie.php) this way:
I write a littel php script (disp_scot.php) containing this:
<?php 
require_once "cfimageget.php";
$cpmfetch = new cfimageget();
$cpmfetch->setSourceString("cat=9");
$cpmfetch->getRandom();
?>

and use it at my page like this:
<a href="/gallerie/index.php?cat=9"><img src="/gallerie/cpmfetch/disp_scot.php" alt="random scot pics" align="left" /></a>
The align=left is used to position the thumb in front of my text and let flow the text around the thumb.

Now I notice that this no longer work with V2.0 or I cannot find out how. All is changed :)
I bring my page to work by replacing the img src code with the propper php code:
<?php
include_once "./gallerie/cpmfetch/cpmfetch.php";
$objCpm = new cpm("./gallerie/cpmfetch/cpmfetch_config.php");
$objCpm->cpm_viewRandomMediaFrom('cat=9',14$options);
$objCpm->cpm_close();
?>

With this I display 4 random pictures direct from cpmfetch. This is a workaround for my but should not the final solution. I like to display one random picture as in my old code to use the alignment. Is there a way to use cpmfetch V2.0 with the img src tag ? I cannot find any examples how to do this.

Regards
Title: Re: How I use cpmfetch V2.x inside img src ?
Post by: vuud on July 05, 2007, 11:16:51 PM
Quote from: Zarzal on July 05, 2007, 09:52:31 AM
Hello,
I use cpmfetch long time. Yesterday I change my webserver and by this way I have to upgrade something. Last version I work with was 1.9x and now I change to V2.0 release.
On my old days I use cpmfetch to display a randon image on my homepage (http://www.biker-reise.de/galerie.php) this way:
I write a littel php script (disp_scot.php) containing this:
<?php 
require_once "cfimageget.php";
$cpmfetch = new cfimageget();
$cpmfetch->setSourceString("cat=9");
$cpmfetch->getRandom();
?>

and use it at my page like this:
<a href="/gallerie/index.php?cat=9"><img src="/gallerie/cpmfetch/disp_scot.php" alt="random scot pics" align="left" /></a>
The align=left is used to position the thumb in front of my text and let flow the text around the thumb.

Now I notice that this no longer work with V2.0 or I cannot find out how. All is changed :)
I bring my page to work by replacing the img src code with the propper php code:
<?php
include_once "./gallerie/cpmfetch/cpmfetch.php";
$objCpm = new cpm("./gallerie/cpmfetch/cpmfetch_config.php");
$objCpm->cpm_viewRandomMediaFrom('cat=9',14$options);
$objCpm->cpm_close();
?>

With this I display 4 random pictures direct from cpmfetch. This is a workaround for my but should not the final solution. I like to display one random picture as in my old code to use the alignment. Is there a way to use cpmfetch V2.0 with the img src tag ? I cannot find any examples how to do this.

Regards

You switched to doing it the normal way.  You should go back to using cfimageget and you can still do it.   Or should be able to anyway.  If not, tell me why...

Title: Re: How I use cpmfetch V2.x inside img src ?
Post by: Zarzal on July 06, 2007, 04:10:31 PM
It seems that I have still some trouble on my new server to use it the old way. I get no image and I dont know why. I will investigate this weekend and will report what I find.
Title: Re: How I use cpmfetch V2.x inside img src ?
Post by: Zarzal on July 06, 2007, 04:22:58 PM
it seems that something is wrong with fopen on my new server. Looks like security restrictions. If I try to call my little php file direct in IE56 I get:
<br />
<b>Warning</b>:  fopen(albums/userpics/robert/tag03/thumb_01JUN19222.jpg): failed to open stream: No such file or directory in <b>/path to my space/schottland-2003.de/gallerie/cpmfetch/cfimageget.php</b> on line <b>263</b><br />

Thats why I dont get a picture on my homepage.
Title: Re: How I use cpmfetch V2.x inside img src ?
Post by: Zarzal on July 06, 2007, 05:25:07 PM
I found whats going on, but dont understand why :) If I change line 233 of cfimageget.php

//$filenametoshow = $_SERVER['DOCUMENT_ROOT'];
$filenametoshow .= $this->cpm->getImageToUse($row['pFilepath'],$row['pFilename'],$this->defaultsize);

to

//$filenametoshow = $_SERVER['DOCUMENT_ROOT'];
$filenametoshow = "http://www.mydomain.tld/coppermineroot/";
$filenametoshow .= $this->cpm->getImageToUse($row['pFilepath'],$row['pFilename'],$this->defaultsize);

it worked as it should. I try to fill out $urltocpm on top of the file but it seems that this is cleared somewhere while executing the script. The hardcode of the missing path statement fix my problem.
Title: Re: How I use cpmfetch V2.x inside img src ?
Post by: vuud on July 06, 2007, 07:27:58 PM
Quote from: Zarzal on July 06, 2007, 04:22:58 PM
it seems that something is wrong with fopen on my new server. Looks like security restrictions. If I try to call my little php file direct in IE56 I get:
<br />
<b>Warning</b>:  fopen(albums/userpics/robert/tag03/thumb_01JUN19222.jpg): failed to open stream: No such file or directory in <b>/path to my space/schottland-2003.de/gallerie/cpmfetch/cfimageget.php</b> on line <b>263</b><br />

Thats why I dont get a picture on my homepage.


Which version do you have?  Try the latest dev version... there was a bug in 2.0 with cfimageget that I think matches this problem (if I recall correctly).
Title: Re: How I use cpmfetch V2.x inside img src ?
Post by: Zarzal on July 06, 2007, 11:29:25 PM
I use V2.0 release. It seems you are right and there is a bug.
Now I run Dev 2.1.1 and it work as it should. Very nice, I learn a lot and use the cfimageget.php direct with parameter in my website instead using another external php file. I like it.
Thanks for support.

http://www.biker-reise.de/galerie.php