/** * A display name handler for media works * * Includes a thumbnail of the work's placard image as part of the display name * * @param mixed $id Reason ID or entity * @return string */ function reason_media_work_display_name_handler($id) { if (!is_object($id)) { $e = new entity($id); } else { $e = $id; } if ($e->get_value('transcoding_status') == 'converting' || $e->get_value('transcoding_status') == 'finalizing') { return '<img src="' . REASON_HTTP_BASE_PATH . 'ui_images/spinner_16.gif" width="16" height="16" alt="Converting" /> ' . $e->get_value('name'); } if ($e->get_value('transcoding_status') == 'error') { return '<img src="' . REASON_HTTP_BASE_PATH . 'silk_icons/error.png" width="16" height="16" alt="Error" /> ' . $e->get_value('name'); } if ($e->get_value('transcoding_status') && ($images = $e->get_left_relationship('av_to_primary_image'))) { $image = current($images); if ($path = reason_get_image_path($image, 'thumbnail')) { if (file_exists($path)) { if ($size = getimagesize($path)) { return '<img src="' . htmlspecialchars(reason_get_image_url($image, 'thumbnail'), ENT_QUOTES) . '" width="' . round($size[0] / 2) . '" height="' . round($size[1] / 2) . '" alt="' . reason_htmlspecialchars(strip_tags($image->get_value('description'))) . '" /> ' . $e->get_value('name'); } } } } switch ($e->get_value('av_type')) { case 'Audio': return '<img src="' . REASON_HTTP_BASE_PATH . 'silk_icons/sound.png" width="16" height="16" alt="Audio" /> ' . $e->get_value('name'); case 'Video': return '<img src="' . REASON_HTTP_BASE_PATH . 'silk_icons/television.png" width="16" height="16" alt="Video" /> ' . $e->get_value('name'); default: return $e->get_value('name'); } }
function run() { if ($this->media_work->get_value('integration_library') == 'kaltura') { // Kill the module if the media work is somehow not a media work video if ($this->media_work->get_value('av_type') != 'Video' || $this->admin_page->type_id != id_of('av')) { die('<p>This module only works with Media Works whose av_type is \'Video\'.</p>'); } // Kill the module if the user doesn't have access to the video $mwh = new media_work_helper($this->media_work); if (!$mwh->user_has_access_to_media()) { die('<p>You do not have permissions to change the still frame for this video.</p>'); } if ($this->cur_image) { echo '<p>This Media Work\'s current placard image is displayed below:</p>' . "\n"; echo '<img src="' . reason_get_image_url($this->cur_image) . '">' . "\n"; echo '<hr />' . "\n"; $choose_img_link = carl_make_redirect(array('cur_module' => 'Associator', 'rel_id' => relationship_id_of('av_to_primary_image'))); echo '<h4><a href="' . $choose_img_link . '">Choose your own image.</a></h4>' . "\n"; echo '<h3>OR</h3>' . "\n"; echo '<h4>Use the slider below to choose a different still frame from the video to use as its placard image.</h4>' . "\n"; } else { echo '<h4>Choose your own image to use as its placard image.</h4>' . "\n"; echo '<h2>OR</h2>' . "\n"; echo '<h4>Use the slider below to choose a still frame from the video to use as its placard image.</h4>' . "\n"; } $this->run_form(); } else { die('<p>This module only applies to kaltura-integrated Media Works.</p>'); } }
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"; }
/** * A display name handler for features * * Includes a thumbnail of one of the feature's images as part of the display name * * @param mixed $id Reason ID or entity * @return string */ function reason_feature_display_name_handler($id) { if (!is_object($id)) { $e = new entity($id); } else { $e = $id; } if ($images = $e->get_left_relationship('feature_to_image')) { $image = reset($images); if ($path = reason_get_image_path($image, 'thumbnail')) { if (file_exists($path)) { if ($size = getimagesize($path)) { return '<img src="' . htmlspecialchars(reason_get_image_url($image, 'thumbnail'), ENT_QUOTES) . '" width="' . round($size[0] / 2) . '" height="' . round($size[1] / 2) . '" alt="' . reason_htmlspecialchars(strip_tags($image->get_value('description'))) . '" /> ' . $e->get_value('name'); } } } } elseif ($media = $e->get_left_relationship('feature_to_media_work')) { $m = reset($media); $images = $m->get_left_relationship('av_to_primary_image'); if (!empty($images)) { $image = reset($images); if ($path = reason_get_image_path($image, 'thumbnail')) { if (file_exists($path)) { if ($size = getimagesize($path)) { return '<img src="' . htmlspecialchars(reason_get_image_url($image, 'thumbnail'), ENT_QUOTES) . '" width="' . round($size[0] / 2) . '" height="' . round($size[1] / 2) . '" alt="' . reason_htmlspecialchars(strip_tags($image->get_value('description'))) . '" /> ' . $e->get_value('name'); } } } } switch ($m->get_value('av_type')) { case 'Audio': return '<img src="' . REASON_HTTP_BASE_PATH . 'silk_icons/sound.png" width="16" height="16" alt="Audio" /> ' . $e->get_value('name'); case 'Video': return '<img src="' . REASON_HTTP_BASE_PATH . 'silk_icons/television.png" width="16" height="16" alt="Video" /> ' . $e->get_value('name'); } } return $e->get_value('name'); }
function run() { // Kill the module if the media work is somehow not a media work video if ($this->media_work->get_value('integration_library') != 'zencoder' || $this->media_work->get_value('av_type') != 'Video' || $this->admin_page->type_id != id_of('av')) { die('<p>This module only works with Zencoder-integrated Media Works whose av_type is \'Video\'.</p>'); } // Kill the module if the user doesn't have access to the video $mwh = new media_work_helper($this->media_work); if (!$mwh->user_has_access_to_media()) { die('<p>You do not have permissions to change the still frame for this video.</p>'); } if (count($this->get_images()) == 0) { die('<p>There are no thumbnails for this media work. Attach an image to this media work if you want to assign it a thumbnail.</p>' . "\n"); } if ($this->cur_image) { echo '<p>This Media Work\'s current thumbnail is displayed below:</p>' . "\n"; echo '<img src="' . reason_get_image_url($this->cur_image) . '">' . "\n"; echo '<hr />' . "\n"; $choose_img_link = carl_make_redirect(array('cur_module' => 'Associator', 'rel_id' => relationship_id_of('av_to_primary_image'))); echo '<h4><a href="' . $choose_img_link . '">Choose your own image.</a></h4>' . "\n"; echo '<h3>OR</h3>' . "\n"; echo '<h4>Use the slider below to choose a different still frame from the video to use as its thumbnail.</h4>' . "\n"; } else { echo '<h4>Choose your own image to use as its placard image.</h4>' . "\n"; echo '<h2>OR</h2>' . "\n"; echo '<h4>Use the slider below to choose a still frame from the video to use as its thumbnail.</h4>' . "\n"; } if (count($this->get_images()) > 1) { echo '<p>There are ' . count($this->get_images()) . ' images to choose from.</p>' . "\n"; } elseif (count($this->get_images()) == 1) { echo '<p>There is only one image to choose from.</p>' . "\n"; } else { echo '<p>There are no images to choose from.</p>' . "\n"; } // provide data for javascript magic echo $this->get_js_data(); $this->run_form(); }
/** * Add basic metadata using the open graph protocol (http://ogp.me/). * * This should improve how shared items appear on facebook and possibly other social networks. * * @todo add integration with propietary tags for specific social networks. */ function _add_open_graph_tags_for_item() { $item = new entity($this->current_item_id); if (reason_is_entity($item, 'news')) { $title = htmlspecialchars(trim(strip_tags($item->get_value('release_title'))),ENT_QUOTES,'UTF-8'); $description = htmlspecialchars(trim(str_replace(' ', '', strip_tags($item->get_value('description')))),ENT_QUOTES,'UTF-8'); if (empty($description)) // lets look to the content field if description is missing. { $content = htmlspecialchars(trim(str_replace(' ', '', strip_tags($item->get_value('content')))),ENT_QUOTES,'UTF-8'); if (!empty($content)) { $words = explode(' ', $content, 31); unset($words[count($words)-1]); $description = implode(' ', $words).'…'; } } $url = carl_construct_link(array(''), array('story_id', 'issue_id', 'section_id')); if ($teaser = $this->get_teaser_image($item)) { $teaser = reset($teaser); $image_urls[] = reason_get_image_url($teaser); } elseif ($images = $this->get_item_images($item)) { foreach ($images as $image) { $image_urls[] = reason_get_image_url($image); } } $site = $this->get_site_entity(); if ($site) $site_name = htmlspecialchars(trim(strip_tags($site->get_value('name'))),ENT_QUOTES,'UTF-8'); $head_items =& $this->get_head_items(); $head_items->add_head_item('meta',array( 'property' => 'og:type', 'content' => 'article')); $head_items->add_head_item('meta',array( 'property' => 'og:title', 'content' => $title)); $head_items->add_head_item('meta',array( 'property' => 'og:url', 'content' => $url)); if (!empty($description)) $head_items->add_head_item('meta',array( 'property' => 'og:description', 'content' => $description)); if (!empty($image_urls)) { foreach ($image_urls as $image_url) { $head_items->add_head_item('meta',array( 'property' => 'og:image', 'content' => 'http://'.$_SERVER['HTTP_HOST'].$image_url)); if (HTTPS_AVAILABLE) $head_items->add_head_item('meta',array( 'property' => 'og:image:secure_url', 'content' => 'https://'.$_SERVER['HTTP_HOST'].$image_url)); } } if (!empty($site_name)) $head_items->add_head_item('meta',array( 'property' => 'og:site_name', 'content' => $site_name)); } }
/** * 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; }
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)) { $primary_image = current($results); return reason_get_image_url($primary_image); } else { return false; } }
function init_avs() { //now get an av, if it exists $fh = new Feature_Helper(); $id = $this->get_value('id'); $av_ids = null; $results_array = $fh->get_avs_associated_with_feature($id); if (!empty($results_array)) { foreach ($results_array as $r) { $tmp = $r->get_value('av_id'); if (is_array($tmp)) { $av_ids = $tmp; } else { if ($tmp != "none") { $av_ids = array(0 => $tmp); } else { $av_ids = array(0 => "none"); } } } } else { $av_ids = array(0 => "none"); } $this->av_ids = $av_ids; $av_html = array(); $av_img_url = array(); $av_img_alt = array(); $av_thumbnail_urls = array(); $av_img_ids = array(); $av_types = array(); foreach ($av_ids as $id) { if ($id != "none") { $av_info = $fh->get_av_info($id, $this->width, $this->height); $av_html[] = htmlspecialchars($av_info['av_html'], ENT_QUOTES); $av_img_url[] = $av_info['av_img_url']; $av_img_alt[] = $av_info['av_img_alt']; if ($av_info['av_img_id'] != "none") { $av_thumbnail_urls[] = reason_get_image_url($av_info['av_img_id'], 'thumbnail'); $av_img_ids[] = $av_info['av_img_id']; } else { $av_thumbnail_urls[] = $av_info['av_img_url']; $av_img_ids[] = "none"; } $av_types[] = $av_info['type']; //pray($av_info); } else { $av_img_url[] = "none"; $av_img_alt[] = ""; $av_thumbnail_urls[] = "none"; $av_img_ids[] = "none"; $av_types[] = "none"; } } $this->av_image_urls = $av_img_url; $this->av_image_alts = $av_img_alt; $this->av_thumbnail_urls = $av_thumbnail_urls; $this->av_img_ids = $av_img_ids; $this->av_types = $av_types; }
/** * Get custom computed values for an image * @access private * @param object (entity) $e * @param string $indent * @return array lines */ function _get_custom_values_for_image($e, $indent) { $lines = array(); $lines[] = $indent . '<value name="url" type="computed">' . htmlspecialchars(reason_get_image_url($e)) . '</value>'; $lines[] = $indent . '<value name="thumb_url" type="computed">' . htmlspecialchars(reason_get_image_url($e, 'thumbnail')) . '</value>'; return $lines; }
/** * 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; }
/** * Assign an image to be used as the placard image * @param mixed $image An image URL, id, or entity */ function set_placard_image($image) { if (is_numeric($image) || is_object($image)) { $this->placard_image_url = reason_get_image_url($image); } elseif (is_string($image)) { $this->placard_image_url = $image; } else { trigger_error('Placard image must be an image id, url, or entity'); } }
protected function get_media_placard_info($media) { if ($placards = $media->get_left_relationship('av_to_primary_image')) { $placard = current($placards); $placard_url = reason_get_image_url($placard, 'tn'); list($width, $height) = getimagesize(reason_get_image_path($placard, 'tn')); } else { $placard_url = REASON_HTTP_BASE_PATH . 'modules/publications/media_placeholder_thumbnail.png'; $width = 125; $height = 70; } return array('url' => $placard_url, 'width' => $width, 'height' => $height); }
/** * 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 get_image_detail_image_info($image) { $image_info = array(); if (is_array($image)) { $image_entity = new entity($image['id']); } elseif (is_object($image)) { if ('reasonSizedImage' == get_class($image)) { $image_entity = new entity($image->get_id()); } else { $image_entity = $image; } } $img_description = $image_entity->get_value('description'); $img_width = $image_entity->get_value('width'); $img_height = $image_entity->get_value('height'); $img_url = reason_get_image_url($image_entity->id()); $img_author = $image_entity->get_value('author'); $title = $image_entity->get_value('description') ? $image_entity->get_value('description') : 'Image'; $image_caption = $image_entity->get_value('content') ? $image_entity->get_value('content') : $image_entity->get_value('description'); $image_info = array('title' => $title, 'caption' => $image_caption, 'url' => $img_url, 'author' => $img_author, 'width' => $img_width, 'height' => $img_height); return $image_info; }
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; } }