function get_markup($events) { $ret = '<div id="eventsGalleryModule" class="bigList">' . "\n"; $ret .= '<ul class="events">' . "\n"; foreach ($events as $event) { $ret .= '<li class="event">' . "\n"; $ret .= '<a href="' . reason_htmlspecialchars($event->get_url()) . '">' . "\n"; $ret .= '<span class="imageWrap">' . "\n"; if ($image = $event->get_image()) { reason_include_once('classes/sized_image.php'); $rsi = new reasonSizedImage(); $rsi->set_id($image->id()); $rsi->set_width(280); $rsi->set_height(200); $url = $rsi->get_url(); $ret .= '<img src="' . htmlspecialchars($url) . '" alt="' . reason_htmlspecialchars(strip_tags($image->get_value('description'))) . '" width="295" height="200" class="primaryImage" />' . "\n"; } $ret .= '</span>' . "\n"; $ret .= '<span class="info">' . "\n"; $ret .= '<span class="meta">' . "\n"; $ret .= '<em class="currency">' . htmlspecialchars($event->temporal_phrase()) . '</em> / '; $ret .= '<span class="dates">' . htmlspecialchars($event->date_range_phrase()) . '</span>' . "\n"; $ret .= '</span><br />' . "\n"; $ret .= '<span class="name">' . "\n"; $ret .= '<strong class="title">'; $ret .= $event->get_main_title($event); if ($sub = $event->get_subtitle($event)) { $ret .= ':'; } $ret .= '</strong>'; if (!empty($sub)) { $ret .= '<span class="subtitle">' . $sub . '</span>' . "\n"; } $ret .= '</span>' . "\n"; $ret .= '</span>' . "\n"; $ret .= '</a>' . "\n"; $ret .= '</li>' . "\n"; } $ret .= '</ul>' . "\n"; $ret .= '</div>' . "\n"; return $ret; }
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"; }
private function _get_poster_image_url() { $es = new entity_selector(); $es->add_type(id_of('image')); $es->add_right_relationship($this->media_work->id(), relationship_id_of('av_to_primary_image')); $results = $es->run_one(); if (!empty($results)) { reason_include_once('classes/sized_image.php'); $primary_image = current($results); $rsi = new reasonSizedImage(); $rsi->set_id($primary_image->id()); $rsi->set_height($this->_get_closest_size($this->get_embed_height(), array(240, 360, 480))); $rsi->allow_enlarge(false); return $rsi->get_url(); } else { return false; } }
/** * 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; }
/** * 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; }
/** * Modify the head items of a Reason page * * This is the primary (and simplest) way for a theme customizer to affect the look of a site. * * @param object $head_items * @return void */ public function modify_head_items($head_items) { $data = $this->get_customizaton_data(); if (!empty($data)) { $css = ''; if (!empty($data->background_color)) { $css .= 'body{background-color:#' . $data->background_color . ';}'; } if (!empty($data->text_color)) { $css .= 'body{color:#' . $data->text_color . ';}'; } if (!empty($data->banner_font)) { $css .= '#banner,.banner{font-family:"' . $data->banner_font . '";}'; } if (!empty($data->banner_image_id)) { $image = new entity($data->banner_image_id); if ($image->get_values() && $image->get_value('type') == id_of('image')) { $rsi = new reasonSizedImage(); $rsi->set_id($data->banner_image_id); $rsi->set_width(1680); $rsi->set_height(205); $css .= '#banner,.banner{background-image:url("' . $rsi->get_url() . '");}'; } else { trigger_error('Banner image ID in theme customizer not valid'); } } $head_items->add_head_item('style', array('type' => 'text/css'), $css); } }
/** * 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; }
/** * If there is no image this is giving us a mess of an image with a huge icon. */ function get_av_img_url($image) { $width = $this->width; $height = $this->height; $crop_style = $this->crop_style; $id = $image->get_value('id'); $rsi = new reasonSizedImage(); $rsi->set_id($id); $rsi->set_width($width); $rsi->set_height($height); $rsi->set_crop_style($crop_style); $watermark = $this->get_watermark_absolute_path($this->media_works_type); $options = array(); $options['horizontal'] = "center"; $options['vertical'] = "center"; $rsi->set_blit($watermark, $options); $rsi->use_absolute_urls($this->use_absolute_urls); $url = $rsi->get_url(); return $url; }
/** * Get HTML to display the sized image and its url at the top of the given form * @param object disco form * @return string HTML to display */ function pre_show_disco(&$disco) { if ($disco->has_errors()) { return ''; } if ($image = $this->_get_image()) { $unsized_width = $image->get_value('width'); $unsized_height = $image->get_value('height'); $sized_width = $disco->get_value('width'); $sized_height = $disco->get_value('height'); if (empty($sized_width) && empty($sized_height) || $unsized_width == $sized_width && $unsized_height == $sized_height) { $showing_normal_size = true; $url = reason_get_image_url($image); } else { $showing_normal_size = false; $rsi = new reasonSizedImage(); $server_path = REASON_SIZED_IMAGE_CUSTOM_DIR; $web_path = REASON_SIZED_IMAGE_CUSTOM_DIR_WEB_PATH; $rsi->set_paths($server_path, $web_path); $rsi->set_id($image->id()); if (!empty($sized_width)) { $rsi->set_width($sized_width); } if (!empty($sized_height)) { $rsi->set_height($sized_height); } if ($disco->get_value('crop')) { $rsi->set_crop_style($disco->get_value('crop')); } $url = $rsi->get_url(); } $ret = '<div class="preview">' . "\n"; $ret .= '<div class="image"><img src="' . htmlspecialchars($url) . '" alt="Image sized to ' . ($sized_width ? $sized_width : 'auto') . ' by ' . ($sized_height ? $sized_height : 'auto') . ' pixels" /></div>' . "\n"; if ($showing_normal_size) { $ret .= '<div class="normalSizeNotice smallText">(This is the standard size of this image.)</div>' . "\n"; } else { $ret .= '<div class="url"><div class="label"><p>To use this image at this size:</p><ol><li>copy this web address</li><li>paste it into the "image at web address" tab in the "insert image" dialog box.</li></ol></div><input type="text" value="' . htmlspecialchars($url) . '" size="50" /></div>' . "\n"; } $ret .= '</div>' . "\n"; if (!$showing_normal_size) { $ret .= '<h4 class="tryAgainHeading">Try another size</h4>' . "\n"; } return $ret; } }
function resize_av_images($image_id_str) { global $d; $img_ids = explode(",", $image_id_str); $types = explode(",", $d['av_type']); $width = (int) $d['w']; $height = (int) $d['h']; $crop_style = $d['crop_style']; $url = array(); $fh = new Feature_Helper(); $curr = 0; foreach ($img_ids as $id) { if ($id != "none") { $rsi = new reasonSizedImage(); $rsi->set_id($id); $rsi->set_width($width); $rsi->set_height($height); $rsi->set_crop_style($crop_style); $watermark = $fh->get_watermark_absolute_path($types[$curr]); //$options=array('horizontal'=>'center','vertical'=>'center'); $options = array(); $options['horizontal'] = "center"; $options['vertical'] = "center"; $rsi->set_blit($watermark, $options); // $rsi->_make(); $url[] = $rsi->get_url(); // $path=$rsi->get_file_system_path_and_file_of_dest(); // blit_image($path,$path,$watermark,$options); $curr++; } } $str = ""; for ($i = 0; $i < count($url); $i++) { $str .= "" . $url[$i] . ","; } $str = trim($str, ","); return $str; }
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; } }