/ Published in: PHP
a customized random image plugin for ndxz v2
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* Format Name: Random Image Format URI: http://www.indexhibit.org/format/random-image/ Description: Returns a random image from the exhibit. Version: 1.0 Author: Indexhibit Author URI: http://indexhibit.org/ Params: format,images Source: exhibit Objects: exhibits */ class Exhibit { function Exhibit() { } function createExhibit() { $OBJ =& get_instance(); global $default; $OBJ->page->exhibit['dyn_css'][] = $this->dynamicCSS(); // exhibit only source $this->source = $default['filesource'][0]; // get images $OBJ->vars->images = $OBJ->page->get_imgs(); // if no images return our text only if (!$OBJ->vars->images[0]) { $OBJ->page->exhibit['exhibit'] = $OBJ->vars->exhibit['content']; return; } $s = "\n<div id='img-container' style='margin-bottom: 3px;'>\n"; // if image { $s .= "<img src='" . $OBJ->vars->images[0][$rand]['media_path'] . "' alt='" . $OBJ->vars->images[0][$rand]['media_title'] . "'/><p class='random_img_title'>" . $OBJ->vars->images[0][$rand]['media_title'] . "</p><p class='random_img_caption'>" . $OBJ->vars->images[0][$rand]['media_caption'] . "</p>"; } else { $mime = $OBJ->vars->images[0][$rand]['media_mime']; $s .= $mime($OBJ->vars->images[0][$rand]['media_file'], $OBJ->vars->images[0][$rand]['media_x'], $OBJ->vars->images[0][$rand]['media_y'], $OBJ->vars->images[0][$rand]['media_thumb']); } $s .= "</div>\n"; $OBJ->page->exhibit['exhibit'] = ($OBJ->vars->exhibit['placement'] == 1) ? $s . $OBJ->vars->exhibit['content'] : $OBJ->vars->exhibit['content'] . $s; return $OBJ->page->exhibit['exhibit']; } function dynamicCSS() { return "#img-container img { display: table; margin: 0 auto; }"; } }