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: displaying images on a different domain  (Read 10112 times)

0 Members and 1 Guest are viewing this topic.

iain sherriff

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 22
displaying images on a different domain
« on: July 31, 2008, 05:10:24 pm »

The installation of cpmfetch was faultless  :)

My gallery is at
lo-rdz.co.uk
[so lo-rdz.co.uk/cpmfetch/ ]

My phpbb3 board is at
lowriderforums.com/forum

I have put the code

Code: [Select]
<?php
  
include "http://www.lo-rdz.co.uk/cpmfetch/cpmfetch.php";
  
$objCpm = new cpm("http://www.lo-rdz.co.uk/cpmfetch/cpmfetch_config.php");
  
$objCpm->cpm_viewLastAddedMedia(1,4);
  
$objCpm->cpm_close();
?>

where i want the images to display................ but nothing shows.
The code is in the .html template [overall_header.html] and is inside the DIV whre you can see the grey bar below the nav section

http://www.lowriderforums.com/forum

What have I missed or need to change plese?
Logged

poubao

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: la
  • Offline Offline
  • Gender: Male
  • Posts: 277
    • Collections du Laos
Re: displaying images on a different domain
« Reply #1 on: July 31, 2008, 06:03:12 pm »

You have missed to read this cpmfetch
try to use relative path like this: ./cpmfetch/cpmfetch.php  and ./cpmfetch/cpmfetch_config.php
poubao :D
Logged
L'incohérence de ceux qui nous dirigent, l'incompétence de ceux qui nous commandent,sont un vibrant hommage pour ceux qui exécutent.
                                          **Général Patton**

iain sherriff

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 22
Re: displaying images on a different domain
« Reply #2 on: July 31, 2008, 06:53:47 pm »

are you saying that I can only use this to display images in a page on the same domain as the cpm ? 
Logged

iain sherriff

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 22
Re: displaying images on a different domain
« Reply #3 on: July 31, 2008, 07:00:12 pm »

are you saying that I can only use this to display images in a page on the same domain as the cpm ? 

reading the docs agin I guess you are......... it doesnt actually say you cant use different domains but all the examples given are on the same domain..........
Logged

capecodgal

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 123
Re: displaying images on a different domain
« Reply #4 on: August 11, 2008, 04:45:17 pm »

it works on different domains and different servers but think about what you are asking for.... you need to use a relative path in cpmfetch so how are you going to do that on a remote server? You can't to my knowledge unless someone knows something different I would love to see how that would work

here's how I made it work - IFRAMES

example create your cpmfetch code in a php file on the server that has the cpmfetch on it. then on the other domain / server use an iframe script to call the php file with the code in it

sure there are other ways- this is just how **I** made mine work

example:

http://disneystarsnetwork.com

the latest photos and videos are all pulled from other domains (same server in this case) but you get the idea this will work on other servers as well
Logged

muskrat

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: displaying images on a different domain
« Reply #5 on: May 30, 2010, 07:30:13 pm »

I've found a way to do this with php, but I'm not sure how clever I am at explaining it.

The problem I had was that for every page on website where I wanted pictures displayed from a different category or album combination, I needed to create a new cpmfetch page on the coppermine website, and then include or get_file_contents it using php. It got tedious after a while with more than a handful of pages. So this is what I did.

1. Add a /cpmfetch/cpmfetch-new.php file on your coppermine website with display configuration you want on display website.
2. On display website, add a file called images-or-something.php that you will include on any page you want to have images from your coppermine website. If you're familiar with php, then save it in your /includes/ folder if you have one. It should have the following php lines:

Code: [Select]
$copperminepath = "http://www.yourcopperminewebsite/cpmfetch/cpmfetch-new.php";
$coppermineimages = file_get_contents($copperminepath);
echo $coppermineimages;

3. On pages where you want images displayed, just include the file from #2.

This works for me on my shared server configuration which won't allow me to fopen, include, fread etc from another domain name, even if it's on the same account. I can't guarantee it works in all situations.

If you want variable output depending on the page content, here's what I did.

4. I have the variable $album which I set in php in header of page before html e.g.

$album = 1
$album = 1,2,3 (yes I think it works when you do this).
etc

Now, go back to step 2, add a ? at the end of the path string, then you can add the $album value as a URL variable to pass through to your coppermine site.

Code: [Select]
$copperminepath = "http://www.yourcopperminewebsite/cpmfetch/cpmfetch-new.php?";
if(isset($album)) {$copperminepath .= 'album='.$album;}
$coppermineimages = file_get_contents($copperminepath);
echo $coppermineimages;

5. In your cpmfetch-new.php file, you need to GET the variables for processing e.g.

Code: [Select]
if(isset($_GET['album')) {$album=$_GET['album'];}
Then somewhere in your code, you need this line

Code: [Select]
$objCpm->cpm_viewRandomMediaFromAlbum(1, 2, $album, $cpmoptions);
Which takes 1 row of 2 images from the albums specified by $album, according to your $cpmoptions array for formatting.

This can be extended to categories also, maybe both. And of course some of the coding can be modified to check if variables are set or not, to sanitize them, etc. I'm only trying to give the general idea.

I tried to do this with both albums and cats and the cpm_viewRandomMediaFrom() function but couldn't get it to work, so have used the cpm_viewRandomMediaFromAlbum and ...FromCategory functions separately.

Sorry if you're not familiar with php, I don't know an easy way to explain how to do this then :(.
Logged

muskrat

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: displaying images on a different domain
« Reply #6 on: July 24, 2010, 07:37:58 pm »

$album = 1,2,3 (yes I think it works when you do this).
A minor update, that line should read

$album = "1,2,3"; or $album = '1,2,3';

i.e. variable needs to be a string. With just one album (or category), quotation marks are not necessary.
Logged
Pages: [1]   Go Up
 

Page created in 0.04 seconds with 19 queries.