function show_list_item($item) { if ($item->get_value('content')) { $caption = $item->get_value('content'); } else { $caption = $item->get_value('description'); } if ($this->params['width'] || $this->params['height']) { $rsi = new reasonSizedImage(); $rsi->set_id($item->id()); if ($this->params['height']) { $rsi->set_height($this->params['height']); } if ($this->params['width']) { $rsi->set_width($this->params['width']); } if ($this->params['crop']) { $rsi->set_crop_style($this->params['crop']); } $image_url = $rsi->get_url(); $width = $rsi->get_image_width(); $height = $rsi->get_image_height(); } else { $image_url = reason_get_image_url($item) . '?cb=' . urlencode($item->get_value('last_modified')); $width = $item->get_value('width'); $height = $item->get_value('height'); } echo '<li>'; if (empty($this->textonly)) { echo '<img src="' . $image_url . '" width="' . $width . '" height="' . $height . '" alt="' . htmlspecialchars(strip_tags($item->get_value('description')), ENT_QUOTES) . '" />'; if ($this->params['show_captions']) { echo '<div class="caption">' . $caption . '</div>' . "\n"; } if ($this->params['show_authors'] && $item->get_value('author')) { echo '<div class="author">Photo: ' . $item->get_value('author') . '</div>' . "\n"; } } else { echo '<a href="' . $image_url . '" title="View image">' . $caption . '</a>' . "\n"; } echo '</li>' . "\n"; }
/** * Returns an array of image info for the given images. * @param array $images array of image entities * @param string $crop Crop style for the reason sized image. May be either 'fill' or 'fit' * @param int $max_height The maximum height of the slideshow * @param int $max_width The maximum width of the slideshow * @return array Each element of the array is an associative array with the folowing keys: description, height, width, url */ function get_slideshow_images_info($images, $crop, $max_height, $max_width) { $images_info = array(); foreach ($images as $image) { $img_description = $image->get_value('description'); $img_content = $image->get_value('content'); $img_author = $image->get_value('author'); $img_height = $image->get_value('height'); $img_width = $image->get_value('width'); //Check if making a reason sized image is necessary. //if ($img_height <= $max_height && $img_width <= $max_width && !$this->params['force_image_enlargement']) //{ // $img_url = reason_get_image_url($image); //} if (0 != $this->params['height'] or 0 != $this->params['width']) { $rsi = new reasonSizedImage(); $rsi->set_id($image->id()); $rsi->set_width($max_width); $rsi->set_height($max_height); //$rsi->allow_enlarge($this->params['force_image_enlargement']); if (!empty($crop)) $rsi->set_crop_style($crop); $img_url = $rsi->get_url(); $img_height = $rsi->get_image_height(); $img_width = $rsi->get_image_width(); } else { $img_url = reason_get_image_url($image); } $images_info[] = array('description' => $img_description, 'content' => $img_content, 'author' => $img_author, 'height' => $img_height, 'width' => $img_width, 'url' => $img_url); } return $images_info; }
/** * Returns an array of image info for the given images. * @param string $crop Crop style for the reason sized image. May be either 'fill' or 'fit' * @return array Each element of the array is an associative array with the folowing keys: description, height, width, url */ function getSlideshowImageInfo() { $crop = $this->getParam('crop', ''); $imageInfo = array(); foreach ($this->images as $image) { $imgDescription = $image->get_value('description'); $imgContent = $image->get_value('content'); $imgAuthor = $image->get_value('author'); $imgHeight = $image->get_value('height'); $imgWidth = $image->get_value('width'); if (0 != $this->maxHeight || 0 != $this->maxWidth) { $rsi = new reasonSizedImage(); $rsi->set_id($image->id()); $rsi->set_width($this->maxWidth); $rsi->set_height($this->maxHeight); if (!empty($crop)) { $rsi->set_crop_style($crop); } $imgUrl = $rsi->get_url(); $imgHeight = $rsi->get_image_height(); $imgWidth = $rsi->get_image_width(); } else { $imgUrl = reason_get_image_url($image); } $imageInfo[] = array('description' => $imgDescription, 'content' => $imgContent, 'author' => $imgAuthor, 'height' => $imgHeight, 'width' => $imgWidth, 'url' => $imgUrl); } if (count($imageInfo) == 0) { trigger_error("No images set for this slideshow"); } return $imageInfo; }
/** * Get information about the placard image to use for a given media file * @param object $media_file * @param mixed $media_work entity object or null. If null, media work will be found * @return array('image'=>entity,'url'=>sized url,'width' =>width,'height'=>height) */ function reason_get_media_placard_image_info($media_file,$media_work = null) { if(empty($media_file)) { trigger_error('reason_get_media_placard_image_info(0 requires a media file as the first argument'); return null; } if($media_file->get_value('av_type') == 'Audio') return null; if(empty($media_work)) { $es = new entity_selector(); $es->add_type(id_of('av')); $es->add_left_relationship($media_file->id(),relationship_id_of('av_to_av_file')); $es->set_num(1); $works = $es->run_one(); if(!empty($works)) $media_work = current($works); else return null; } $es = new entity_selector(); $es->add_type(id_of('image')); $es->add_right_relationship($media_work->id(),relationship_id_of('av_to_primary_image')); $es->set_num(1); $images = $es->run_one(); if(!empty($images)) { $image = current($images); $rsi = new reasonSizedImage(); $rsi->set_id($image->id()); $width = 480; $height = 320; if($media_file->get_value('width') && $media_file->get_value('height')) { $width = $media_file->get_value('width'); $height = $media_file->get_value('height'); } $rsi->set_width($width); $rsi->set_height($height); $rsi->set_crop_style('fill'); $image_url = $rsi->get_url(); return array( 'image' => $image, 'url' => $image_url, 'width' => $rsi->get_image_width(), 'height' => $rsi->get_image_height() ); } return null; }
function show_image($image, $thumbnail = true) { if ($thumbnail) { if (0 != $this->params['thumbnail_height'] or 0 != $this->params['thumbnail_width']) { $rsi = new reasonSizedImage(); $rsi->set_id($image->id()); if (0 != $this->params['thumbnail_height']) { $rsi->set_height($this->params['thumbnail_height']); } if (0 != $this->params['thumbnail_width']) { $rsi->set_width($this->params['thumbnail_width']); } if ('' != $this->params['thumbnail_crop']) { $rsi->set_crop_style($this->params['thumbnail_crop']); } $width = $rsi->get_image_width(); $height = $rsi->get_image_height(); $image_url = $rsi->get_url(); $image_path = $rsi->get_file_system_path_and_file_of_dest(); } else { $image_path = reason_get_image_path($image, 'tn'); $image_url = reason_get_image_url($image, 'tn'); if (!file_exists($image_path)) { $image_path = reason_get_image_path($image); $image_url = reason_get_image_url($image); } list($width, $height) = getimagesize($image_path); } $class = 'thumbnail'; } elseif (!$thumbnail) { if (0 != $this->params['height'] or 0 != $this->params['width']) { $rsi = new reasonSizedImage(); $rsi->set_id($image->id()); if (0 != $this->params['height']) { $rsi->set_height($this->params['height']); } if (0 != $this->params['width']) { $rsi->set_width($this->params['width']); } if ('' != $this->params['crop']) { $rsi->set_crop_style($this->params['crop']); } $width = $rsi->get_image_width(); $height = $rsi->get_image_height(); $image_url = $rsi->get_url(); $image_path = $rsi->get_file_system_path_and_file_of_dest(); } else { $image_path = reason_get_image_path($image); list($width, $height) = getimagesize($image_path); $image_url = reason_get_image_url($image); } $class = 'mainImage'; } if (file_exists($image_path)) { $alt = $image->get_value('description'); if (!$alt) { $alt = $image->get_value('keywords'); if (!$alt) { $alt = $image->get_value('name'); } } $mod_time = filemtime($image_path); return $this->show_image_markup($image_url, $height, $width, $alt, $class, $mod_time); } else { return false; } }