Zenphoto as a plugin

I have done some experimentation in responding to a post here on the forum. Thought I'd share the findings with everyone.

You can use zenphoto functions on any of your WEB pages so long as you successfully inclucde `template-functions.php` in your page. To do so, include the following PHP. This assumes that your zenphoto installation is in a folder named `zenphoto`.

`<?php <br />
define('ZENFOLDER', 'zp-core');

define('WEBPATH', 'zenphoto');

require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");

?>`

Comments

  • I have tried this but I'm getting an error message stating that zenphoto cannot connect to the database. My zenphoto install works perfectly otherwise. Any thoughts?
  • here is the full source of an index.php that works. It displays a random image.

    `<?php <br />
    define('ZENFOLDER', 'zp-core');

    define('WEBPATH', 'zenphoto');

    require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");

    header ('Content-Type: text/html; charset=' . getOption('charset'));

    ?>





    Test Index





    <?php <br />
    $randomImage = getRandomImages();

    $randomImageURL = getURL($randomImage);

    echo "image
    $randomImage->getSizedImage(getOption('image_size')) .

    "' alt=\"random image\"n" . $randomImage->getTitle() .

    '" />
    ';

    ?>



    `

    This file is in the root folder of the site. Zenphoto is installed in the folder `zenphoto`.

    Try it out and see if you get the same result.

    Also, please describe the geography of your site. What is the folder structure. Where is zenphoto and where is the "plug-in" use. Where in your plug-in code does the error message occur?
  • how to use that with two different galleries ? i want to show on one page a link to two different galleries with random thumb_img - is that possible ?
  • That has never been tried. And it probably cannot be made to work since the environment setup needs to be done before headers are sent and you would have to set up two different environments.
  • $randomImage->getSizedImage(getOption('image_size')) .

    how do i get instead of image_size the crop_image_sized thumbnails ?
    thumb_size i tried but it's not working like in the gallery

    can u please help me.
  • thx for your help, but i don't get it working, i'm not used to php that much.
    so i tried a view things but always i got errors or the image was in original size.

    where i have it to fill in ?
    i think i'm not right when i think in this section instead of image_size, cause that didn't work correktly.

    echo "<img src='".
    $randomImage->getSizedImage(getOption('image_size')) .
    "' alt=\"random image\"n" . $randomImage->getTitle() .
    '" />
    ';

    can you please post the whole code for me?
Sign In or Register to comment.