mirror of
https://github.com/danpros/htmly.git
synced 2026-04-21 21:16:23 +05:30
Improve featured video
The `$p->video` should return the video link only, to get the video ID we can use get_video_id(); and call it from the theme.
This commit is contained in:
parent
21d9bbb9b9
commit
84f4e565e6
13 changed files with 15 additions and 136 deletions
|
|
@ -315,7 +315,7 @@ function get_posts($posts, $page = 1, $perpage = 0)
|
|||
// Extract the title and body
|
||||
$post->title = get_content_tag('t', $content, 'Untitled: ' . date('l jS \of F Y', $post->date));
|
||||
$post->image = get_content_tag('image', $content);
|
||||
$post->video = get_youtube_id(get_content_tag('video', $content));
|
||||
$post->video = get_content_tag('video', $content);
|
||||
$post->link = get_content_tag('link', $content);
|
||||
$post->quote = get_content_tag('quote', $content);
|
||||
$post->audio = get_content_tag('audio', $content);
|
||||
|
|
@ -3027,8 +3027,8 @@ function isCaptcha($reCaptchaResponse)
|
|||
return ($json['success']);
|
||||
}
|
||||
|
||||
// Get YouTube video ID
|
||||
function get_youtube_id($url)
|
||||
// Get video ID
|
||||
function get_video_id($url)
|
||||
{
|
||||
if(empty($url)) {
|
||||
return;
|
||||
|
|
@ -3167,127 +3167,6 @@ function rename_category_folder($string, $old_url)
|
|||
|
||||
}
|
||||
|
||||
// Migrate old content.
|
||||
function migrate_old_content()
|
||||
{
|
||||
$content = array();
|
||||
$tmp = array();
|
||||
$files = array();
|
||||
$draft = array();
|
||||
$dtmp = array();
|
||||
$dfiles = array();
|
||||
|
||||
$tmp = glob('content/*/blog/*.md', GLOB_NOSORT);
|
||||
if (is_array($tmp)) {
|
||||
foreach ($tmp as $file) {
|
||||
$content[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($content)) {
|
||||
|
||||
foreach ($content as $c => $v) {
|
||||
$arr = explode('/', $v);
|
||||
$string = file_get_contents($v);
|
||||
$image = get_content_tag('image', $string);
|
||||
$video = get_youtube_id(get_content_tag('video', $string));
|
||||
$audio = get_content_tag('audio', $string);
|
||||
$link = get_content_tag('link', $string);
|
||||
$quote = get_content_tag('quote', $string);
|
||||
if (!empty($image)) {
|
||||
$files[] = array($v, 'content/' . $arr[1] . '/blog/uncategorized/image/' . $arr[3]);
|
||||
$dir = 'content/' . $arr[1] . '/blog/uncategorized/image/';
|
||||
if (!is_dir($dir)) {
|
||||
mkdir($dir, 0775, true);
|
||||
}
|
||||
}
|
||||
if (!empty($video)) {
|
||||
$files[] = array($v, 'content/' . $arr[1] . '/blog/uncategorized/video/' . $arr[3]);
|
||||
$dir = 'content/' . $arr[1] . '/blog/uncategorized/video/';
|
||||
if (!is_dir($dir)) {
|
||||
mkdir($dir, 0775, true);
|
||||
}
|
||||
}
|
||||
if (!empty($audio)) {
|
||||
$files[] = array($v, 'content/' . $arr[1] . '/blog/uncategorized/audio/' . $arr[3]);
|
||||
$dir = 'content/' . $arr[1] . '/blog/uncategorized/audio/';
|
||||
if (!is_dir($dir)) {
|
||||
mkdir($dir, 0775, true);
|
||||
}
|
||||
}
|
||||
if (!empty($link)) {
|
||||
$files[] = array($v, 'content/' . $arr[1] . '/blog/uncategorized/link/' . $arr[3]);
|
||||
$dir = 'content/' . $arr[1] . '/blog/uncategorized/link/';
|
||||
if (!is_dir($dir)) {
|
||||
mkdir($dir, 0775, true);
|
||||
}
|
||||
}
|
||||
if (!empty($quote)) {
|
||||
$files[] = array($v, 'content/' . $arr[1] . '/blog/uncategorized/quote/' . $arr[3]);
|
||||
$dir = 'content/' . $arr[1] . '/blog/uncategorized/quote/';
|
||||
if (!is_dir($dir)) {
|
||||
mkdir($dir, 0775, true);
|
||||
}
|
||||
}
|
||||
if (empty($image) && empty($video) && empty($audio) && empty($link) && empty($quote)) {
|
||||
$files[] = array($v, 'content/' . $arr[1] . '/blog/uncategorized/post/' . $arr[3]);
|
||||
$dir = 'content/' . $arr[1] . '/blog/uncategorized/post/';
|
||||
if (!is_dir($dir)) {
|
||||
mkdir($dir, 0775, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($files as $f) {
|
||||
rename($f[0], $f[1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$dir = 'content/data/';
|
||||
if (!is_dir($dir)) {
|
||||
mkdir($dir, 0775, true);
|
||||
}
|
||||
|
||||
if (file_exists('content/tags.lang')) {
|
||||
rename('content/tags.lang', 'content/data/tags.lang');
|
||||
unlink('content/views.json');
|
||||
}
|
||||
|
||||
$dtmp = glob('content/*/draft/*.md', GLOB_NOSORT);
|
||||
$old = array();
|
||||
if (is_array($dtmp)) {
|
||||
foreach ($dtmp as $dfile) {
|
||||
$draft[] = $dfile;
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($draft)) {
|
||||
foreach ($draft as $d => $val) {
|
||||
$arr = explode('/', $val);
|
||||
$old[] = 'content/' . $arr[1] . '/draft/';
|
||||
$dir = 'content/' . $arr[1] . '/blog/uncategorized/draft/';
|
||||
$new = 'content/' . $arr[1] . '/blog/uncategorized/draft/' . $arr[3];
|
||||
if (!is_dir($dir)) {
|
||||
mkdir($dir, 0775, true);
|
||||
}
|
||||
$dfiles[] = array($val, $new);
|
||||
}
|
||||
|
||||
foreach ($dfiles as $fd) {
|
||||
rename($fd[0], $fd[1]);
|
||||
}
|
||||
$tt = array();
|
||||
$tt = array_unique($old, SORT_REGULAR);
|
||||
foreach ($tt as $t) {
|
||||
rmdir($t);
|
||||
}
|
||||
}
|
||||
|
||||
rebuilt_cache('all');
|
||||
|
||||
}
|
||||
|
||||
function replace_href($string, $tag, $class, $url)
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
<?php } ?>
|
||||
<?php if (!empty($p->video)) { ?>
|
||||
<div class="featured featured-video embed-responsive embed-responsive-16by9">
|
||||
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo $p->video; ?>" frameborder="0" allowfullscreen></iframe>
|
||||
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if (!empty($p->audio)) { ?>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
<?php } ?>
|
||||
<?php if (!empty($p->video)) { ?>
|
||||
<div class="featured featured-video embed-responsive embed-responsive-16by9">
|
||||
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo $p->video; ?>" frameborder="0" allowfullscreen></iframe>
|
||||
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if (!empty($p->audio)) { ?>
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
<?php } ?>
|
||||
<?php if (!empty($p->video)) { ?>
|
||||
<div class="featured-video">
|
||||
<iframe src="https://www.youtube.com/embed/<?php echo $p->video; ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
|
||||
<iframe src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if (!empty($p->audio)) { ?>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<?php } ?>
|
||||
<?php if (!empty($p->video)) { ?>
|
||||
<div class="featured-video">
|
||||
<iframe src="https://www.youtube.com/embed/<?php echo $p->video; ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
|
||||
<iframe src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if (!empty($p->audio)) { ?>
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
<?php } ?>
|
||||
<?php if (!empty($p->video)) { ?>
|
||||
<div class="featured-video">
|
||||
<iframe src="https://www.youtube.com/embed/<?php echo $p->video; ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
|
||||
<iframe src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if (!empty($p->audio)) { ?>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<?php } ?>
|
||||
<?php if (!empty($p->video)) { ?>
|
||||
<div class="featured-video">
|
||||
<iframe src="https://www.youtube.com/embed/<?php echo $p->video; ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
|
||||
<iframe src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if (!empty($p->audio)) { ?>
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
<?php } ?>
|
||||
<?php if (!empty($p->video)) { ?>
|
||||
<div class="featured-video">
|
||||
<iframe src="https://www.youtube.com/embed/<?php echo $p->video; ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
|
||||
<iframe src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if (!empty($p->audio)) { ?>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<?php } ?>
|
||||
<?php if (!empty($p->video)) { ?>
|
||||
<div class="featured-video">
|
||||
<iframe src="https://www.youtube.com/embed/<?php echo $p->video; ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
|
||||
<iframe src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if (!empty($p->audio)) { ?>
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
<?php endif; ?>
|
||||
<?php if (!empty($p->video)):?>
|
||||
<div class="post-thumbnail">
|
||||
<iframe width="100%" height="315px" class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo $p->video; ?>" frameborder="0" allowfullscreen></iframe>
|
||||
<iframe width="100%" height="315px" class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($p->quote)):?>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
<?php endif; ?>
|
||||
<?php if (!empty($p->video)):?>
|
||||
<div class="post-thumbnail">
|
||||
<iframe width="100%" height="315px" class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo $p->video; ?>" frameborder="0" allowfullscreen></iframe>
|
||||
<iframe width="100%" height="315px" class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($p->quote)):?>
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
<blockquote><?php echo $p->quote;?></blockquote>
|
||||
<?php endif;?>
|
||||
<?php if (!empty($p->video)):?>
|
||||
<span class="embed-youtube"><iframe width="100%" height="315px" class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo $p->video; ?>" frameborder="0" allowfullscreen></iframe></span>
|
||||
<span class="embed-youtube"><iframe width="100%" height="315px" class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" frameborder="0" allowfullscreen></iframe></span>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($p->audio)):?>
|
||||
<span class="embed-soundcloud"><iframe width="100%" height="200px" class="embed-responsive-item" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=<?php echo $p->audio;?>&auto_play=false&visual=true"></iframe></span>
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
<blockquote><?php echo $p->quote;?></blockquote>
|
||||
<?php endif;?>
|
||||
<?php if (!empty($p->video)):?>
|
||||
<span class="embed-youtube"><iframe width="100%" height="315px" class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo $p->video; ?>" frameborder="0" allowfullscreen></iframe></span>
|
||||
<span class="embed-youtube"><iframe width="100%" height="315px" class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" frameborder="0" allowfullscreen></iframe></span>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($p->audio)):?>
|
||||
<span class="embed-soundcloud"><iframe width="100%" height="200px" class="embed-responsive-item" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=<?php echo $p->audio;?>&auto_play=false&visual=true"></iframe></span>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue