How to include Random image or video into HTML page ??

hi

can anyone help me How to include Random image or video into HTML page ??

regards

Comments

  • hi acrylian

    i did not get 100%

    i am not that good with php files.

    my zendphoto folder are inside my site folder directory_path.

    i need to have a box of random images and another one for video.

    the page is html so what is the html code should i use to execute the random image or video from the zendphoto??

    regards
  • acrylian Administrator, Developer
    You need a php file, meaning a file with .php as suffix to execute php functions. On a .html page that will not work because the server won't recognize it as php. You can just rename your .hml file to .php. That does not really matter.

    Try adding the code here http://www.zenphoto.org/2008/01/hacks/#zenphoto-as-plugin

    I hope that helps a little more.
  • hi acrylian

    how about if i create a php file like:

    <?php

    define('ZENFOLDER', 'zp-core');
    define('WEBPATH', 'zenphoto');
    require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");

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

    ?>

    than include the php into the html file is is will work??

    regards
  • acrylian Administrator, Developer
    No. Why don't you just rename your .html file? That does not make any difference for the html part of that file.
  • hi

    if i rename the file to php is that all i have to insert into the box where i want the random image to show:

    define('ZENFOLDER', 'zp-core');
    define('WEBPATH', 'zenphoto');
    require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");

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

    regards
  • acrylian Administrator, Developer
    the define and the require_once should be on top of the file, the other code should go where you want the random image.
    php code within a html code must always be enclosed in <?php and ?>.
  • hi acrylian

    so inside the php file the script should looks like:

    on top:

    <?php
    define('my gallery folder name', 'zp-core');
    define('WEBPATH', 'the exact folder name in the albums');
    require_once(WEBPATH . "/" . 'my gallery folder name . "/template-functions.php");

    ?>

    than anywhere:

    <?php

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

    ?>

    if not correct could u pls correct it for me

    regards
  • hi acrylian

    sorry, inside the php file the script should looks like:

    <?php ----begining of the php

    on top:

    define('my gallery folder name', 'zp-core');
    define('WEBPATH', 'the exact folder name in the albums');
    require_once(WEBPATH . "/" . 'my gallery folder name . "/template-functions.php");

    than anywhere:

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

    ?> -------end of the php

    if not correct could u pls correct it for me especialy the 2 define and the require.

    regards
  • acrylian Administrator, Developer
    Your post before your last should work.
  • hi acrylian

    the script working 100% but to include Random images or videos into my home website is a nughtmare.

    unfortanatly, i can not change the file name from html into php. this is how the site was developed.

    can u find me another solution for this html issue pls?

    regards
  • acrylian Administrator, Developer
    No, sorry.
  • hi acrylian

    ok, i will give it another shot and try something else.

    first i need to meke sure of this bellow:

    define('ZENFOLDER', 'zp-core'); (for this one what folder they mean in this)

    define('WEBPATH', 'zenphoto'); (for this one what path they mean in this)

    require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php"); (for this one what folder they mean in this)
  • acrylian Administrator, Developer
    define('ZENFOLDER', 'zp-core'); (for this one what folder they mean in this)
    the zp-core folder within you zenphoto installation

    define('WEBPATH', 'zenphoto'); (for this one what path they mean in this)
    the folder of your zenphoto installation, you have of course to change that if you renamed it.

    require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php"); (for this one what folder they mean in this)
    The ones you defined above...
  • hi acrylian

    nothing seems to work

    hope in the next version they take care of how or a simple way to " include Random image or video into HTML pages"

    thanks
  • acrylian Administrator, Developer
    As I said above php code does not work on .html pages. You need to use a .php file. This is not a zenphoto issue.
  • try

    `AddType application/x-httpd-php .html`

    in your .htaccess file

    Or even

    `

    AddType application/x-httpd-php .html

    `

    to make it just process PHP for a specific file.

    Alternatively, you can put rewrite rule in .htaccess to internally redirect the call to the .html URL to your .php version.

    `RewriteRule ^example.html$ example.php [L]`

    If you can't change your .htaccess, or your host doesn't let use AddType or rewrites, then you might be stuck. The only other thing I could think of would be to get the HTML page to redirect to the PHP pages -- either with a meta refresh tag or some document.location JavaScript.

    And as an absolute last option, you can have a random image picked and displayed solely by JavaScript. This would requiring you updating the page each time you want to change the list of possible images it picks from, though.

    Lots of options :)
  • hi AlexWilson

    thanks for your reply

    i am not that familiar with php.

    however, the htaccess file for my website i can open it from my ftp no problems.

    can u pls guide me step by step how to go in this process to get the random working on my html page.

    the : zenphoto folder in this case named : mediabox.

    also is it possible to have random for specific folders in the album??

    thanks
Sign In or Register to comment.