1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-19 04:02:28 +02:00

Basic support for news videos.

Add {NEWSVIDEO} to your news template to take advantage of it and {NEWSTHUMBNAIL} for a thumbnail image of the video. (or image) {NEWSIMAGE} will return nothing for videos, only for images.
This commit is contained in:
Cameron 2014-01-31 01:09:24 -08:00
parent 19b5dd8614
commit cc07dac897
8 changed files with 100 additions and 46 deletions

View File

@ -735,6 +735,14 @@ class news_form_ui extends e_admin_form_ui
{
if(!vartrue($curval)) return;
$vparm = array('thumb'=>'tag','w'=> 80);
if($thumb = e107::getParser()->toVideo($curval,$vparm))
{
return $thumb;
}
if($curval[0] != "{")
{
$curval = "{e_IMAGE}newspost_images/".$curval;
@ -2378,12 +2386,12 @@ class admin_newspost
".$frm->help(LAN_NEWS_23)."</td>
<td>
";
if(vartrue($_POST['news_thumbnail']) && $_POST['news_thumbnail'][0] != "{")//BC compat
if(vartrue($_POST['news_thumbnail']) && $_POST['news_thumbnail'][0] != "{" && substr($_POST['news_thumbnail'],-8) !== '.youtube')//BC compat
{
$_POST['news_thumbnail'] = "{e_IMAGE}newspost_images/".$_POST['news_thumbnail'];
}
$text .= $frm->imagepicker('news_thumbnail[0]', $_POST['news_thumbnail'] ,'','news');
$text .= $frm->imagepicker('news_thumbnail[0]', $_POST['news_thumbnail'] ,'','media=news&video=1');
/*
* XXX Experimental

View File

@ -201,7 +201,7 @@ class news_shortcodes extends e_shortcode
/**
* {NEWSCOMMENTLINK: glyph=comments&class=btn btn-default btn-sm}
*/
function sc_newscommentlink($parm)
function sc_newscommentlink($parm='')
{
if($this->commentsDisabled)
{
@ -216,7 +216,7 @@ class news_shortcodes extends e_shortcode
/**
* {NEWSCOMMENTCOUNT: glyph=x}
*/
function sc_newscommentcount($parm)
function sc_newscommentcount($parm='')
{
if($this->commentsDisabled)
{
@ -362,18 +362,31 @@ class news_shortcodes extends e_shortcode
*
* @see eHelper::scDualParams()
* @see eHelper::scParams()
* XXX Also returns Video thumbnails.
*/
function sc_newsthumbnail($parm = '')
function sc_newsthumbnail($parm = '') //TODO Add support {NEWSTHUMBNAIL: x=y} format
{
if(!$this->news_item['news_thumbnail'])
if(!$this->news_item['news_thumbnail'] && $parm != 'placeholder')
{
return '';
}
$parms = eHelper::scDualParams($parm);
// We store SC path in DB now + BC
$_src = $src = $this->news_item['news_thumbnail'][0] == '{' ? e107::getParser()->replaceConstants($this->news_item['news_thumbnail'], 'abs') : e_IMAGE_ABS."newspost_images/".$this->news_item['news_thumbnail'];
if($parms[2]) $src = e107::getParser()->thumbUrl($src, $parms[2]);
if($vThumb = e107::getParser()->toVideo($this->news_item['news_thumbnail'], array('thumb'=>'src')))
{
$src = $vThumb;
$_src = '#';
}
else
{
$parms = eHelper::scDualParams($parm);
// We store SC path in DB now + BC
$_src = $src = ($this->news_item['news_thumbnail'][0] == '{' || $parms[1] == 'placeholder') ? e107::getParser()->replaceConstants($this->news_item['news_thumbnail'], 'abs') : e_IMAGE_ABS."newspost_images/".$this->news_item['news_thumbnail'];
if($parms[2] || $parms[1] == 'placeholder') $src = e107::getParser()->thumbUrl($src, $parms[2]);
}
switch($parms[1])
{
case 'src':
@ -389,7 +402,7 @@ class news_shortcodes extends e_shortcode
break;
default:
return "<a href='".e107::getUrl()->create('news/view/item', $this->news_item)."'><img class='news_image img-rounded' src='".$src."' alt='' style='".$this->param['thumbnail']."' /></a>";
return "<a href='".e107::getUrl()->create('news/view/item', $this->news_item)."'><img class='news_image img-responsive img-rounded' src='".$src."' alt='' style='".$this->param['thumbnail']."' /></a>";
break;
}
}
@ -429,40 +442,58 @@ class news_shortcodes extends e_shortcode
}
function sc_newsvideo($parm='')
{
if($video = e107::getParser()->toVideo($this->news_item['news_thumbnail']))
{
return $video;
}
}
/**
* Display News Images (but not video thumbnails )
*/
function sc_newsimage($parm = '')
{
$tp = e107::getParser();
$srcPath = ($this->imageItem) ? $this->imageItem : $this->news_item['news_thumbnail'];
if(!$srcPath)
if($video = e107::getParser()->toVideo($this->news_item['news_thumbnail']))
{
if($parm == 'placeholder')
return;
}
else
{
if(!$srcPath)
{
$src = $tp->thumbUrl(); // placeholder;
if($parm == 'placeholder')
{
$src = $tp->thumbUrl(); // placeholder;
}
else
{
return;
}
}
elseif($srcPath[0] == '{' ) // Always resize. Use {SETIMAGE: w=x&y=x&crop=0} PRIOR to calling shortcode to change.
{
$src = $tp->thumbUrl($srcPath);
}
else
{
return;
// We store SC path in DB now + BC
$src = $srcPath[0] == '{' ? $tp->replaceConstants($srcPath, 'abs') : e_IMAGE_ABS."newspost_images/".$srcPath;
}
}
elseif($srcPath[0] == '{' ) // Always resize. Use {SETIMAGE: w=x&y=x&crop=0} PRIOR to calling shortcode to change.
{
$src = $tp->thumbUrl($srcPath);
}
else
{
// We store SC path in DB now + BC
$src = $srcPath[0] == '{' ? $tp->replaceConstants($srcPath, 'abs') : e_IMAGE_ABS."newspost_images/".$srcPath;
}
;
// return $src;
switch($parm)
{
@ -481,6 +512,8 @@ class news_shortcodes extends e_shortcode
}
}
function sc_sticky_icon()
{
return $this->news_item['news_sticky'] ? $this->param['image_sticky'] : '';

View File

@ -2833,7 +2833,7 @@ class e_parser
if($thumb == 'tag')
{
return "<img class='img-responsive' src='".$thumbSrc."' alt='' style='max-width:".vartrue($parm['w'],'80')."px'/>";
return "<img class='img-responsive' src='".$thumbSrc."' alt='Youtube Video' style='max-width:".vartrue($parm['w'],'80')."px'/>";
}
if($thumb == 'src')

View File

@ -485,9 +485,11 @@ class e_form
* @param string $label custom label
* @param string $sc_parameters shortcode parameters
* --- SC Parameter list ---
* - media: if present - load from media table
* - media: if present - load from media category table
* - w: preview width in pixels
* - h: preview height in pixels
* - help: tooltip
* - video: when set to true, will enable the Youtube (video) tab.
* @example $frm->imagepicker('banner_image', $_POST['banner_image'], '', 'banner'); // all images from category 'banner_image' + common images.
* @example $frm->imagepicker('banner_image', $_POST['banner_image'], '', 'media=banner&w=600');
* @return string html output
@ -509,19 +511,23 @@ class e_form
$default_thumb = $default;
if($default)
{
if('{' != $default[0])
{
// convert to sc path
$default_thumb = $tp->createConstants($default, 'nice');
$default = $tp->createConstants($default, 'mix');
}
$default_url = $tp->replaceConstants($default, 'abs');
$blank = FALSE;
if($video = $tp->toVideo($default_url, array('thumb'=>'src')))
if($video = $tp->toVideo($default, array('thumb'=>'src')))
{
$default_url = $video;
}
else
{
if('{' != $default[0])
{
// convert to sc path
$default_thumb = $tp->createConstants($default, 'nice');
$default = $tp->createConstants($default, 'mix');
}
$default_url = $tp->replaceConstants($default, 'abs');
}
$blank = FALSE;
}
else
{
@ -530,6 +536,8 @@ class e_form
$blank = TRUE;
}
//$width = intval(vartrue($sc_parameters['width'], 150));
$cat = $tp->toDB(vartrue($sc_parameters['media']));

View File

@ -72,7 +72,7 @@ define("NWSLAN_59", "No submitted news");
define("NWSLAN_63", "Search newsposts");
define("NWSLAN_66", "Upload");
define("NWSLAN_67", "Image");
define("NWSLAN_67", "Image/Video");
// define("NWSLAN_68", "File");
define("NWSLAN_69", "Upload an image or file for use in the news item");
// define("NWSLAN_70", "The ".e_FILE."downloads folder is not writable, you need to CHMOD 777 the folder before uploading and files."); // deprecated see lan_admin.php
@ -146,7 +146,7 @@ define("NWSLAN_128", "Set a string to be used in news pages URL. This will only
// define("LAN_NEWS_21", "News updated in database.");
// define("LAN_NEWS_22", "Thumbnail");
define("LAN_NEWS_23", "Choose an image for this news item");
define("LAN_NEWS_23", "Choose an image or video for this news item");
// define("LAN_NEWS_24", "Image + Auto-Thumbnail");
// define("LAN_NEWS_25", "Auto-Thumbnail size");
// define("LAN_NEWS_26", "add new upload field");

View File

@ -31,7 +31,7 @@ $NEWS_TEMPLATE['list']['item'] = '
<div class="row row-fluid">
<div class="span3 col-md-3">
<div class="thumbnail">
{NEWSIMAGE=placeholder}
{NEWSTHUMBNAIL=placeholder}
</div>
</div>
<div class="span9 col-md-9">
@ -93,6 +93,7 @@ $NEWS_TEMPLATE['default']['item'] = '
<hr>
<p class="lead">{NEWSSUMMARY}</p>
{NEWSVIDEO}
{NEWSBODY}
<hr>
<div class="options">
@ -126,6 +127,7 @@ $NEWS_TEMPLATE['view']['item'] = '
<hr>
<div class="body">
{NEWSVIDEO}
{NEWSBODY}
{EXTENDED}
</div>

View File

@ -28,6 +28,7 @@ function tablestyle($caption, $text, $mode='')
{
global $style;
echo "<!-- tablestyle: style=".$style." mode=".$mode." -->\n\n";
$type = $style;
if(empty($caption))
@ -180,8 +181,9 @@ $LAYOUT['modern_business_home'] = <<<TMPL
<div class="container">
{ALERTS}
<!-- Start Menu 1 -->
{MENU=1}
<!-- End Menu 1 -->
</div>
<div class="section">

View File

@ -223,6 +223,7 @@ div.e-comment-edit-save { margin-top:8px; padding: 5px }
position: relative;
padding-bottom: 56.25%;
padding-top: 30px; height: 0; overflow: hidden;
margin-bottom:20px;
}
.video-responsive iframe,