diff --git a/README.md b/README.md index c32dcb7..936622f 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ If no thumbnail image is uploaded, the add/edit forms can auto-grab one from the ### Live Homepage Option -The homepage can show a **Videos / Live** switch above the main player. Configure it in **Admin → Settings → Live Section** with either a direct embeddable URL or an iframe snippet. The default live embed is `https://stream.place/embed/tyclifford.com`. Disable the setting to return the homepage to the normal video-only layout. +The homepage can show a **Videos / Live** switch above the main player. Configure it in **Admin → Settings → Live Section** with either a direct embeddable URL or an iframe snippet. The default live embed is `https://stream.place/embed/tyclifford.com`. Use `?land=live` on the homepage URL to open with the live embed displayed first. Disable the setting to return the homepage to the normal video-only layout. ### Importing YouTube Channels diff --git a/changelog.md b/changelog.md index 3000680..e8e298b 100644 --- a/changelog.md +++ b/changelog.md @@ -19,6 +19,7 @@ All notable changes to this media player project. - Added public search for published videos. - Added configurable URL rewriting, defaulting to `/v/`, `/all`, and `/search/`. - Added a configurable homepage live section with a Videos/Live toggle and default Stream.Place embed support. +- Added `?land=live` homepage support so the live embed can be displayed first from a shareable landing URL. - Added social sharing metadata so video pages expose title, description, and thumbnail image data for link previews. ### Changed diff --git a/index.php b/index.php index 8e0f2b1..16dea3b 100644 --- a/index.php +++ b/index.php @@ -20,8 +20,16 @@ if (!$video) { if ($latest) $video = get_video_by_slug($latest['slug']); } +$live_enabled = live_enabled(); +$live_url = $live_enabled ? live_embed_url() : ''; +$live_title = live_embed_title(); +$requested_land = strtolower(trim(is_scalar($_GET['land'] ?? '') ? (string)$_GET['land'] : '')); +$home_live_first = $live_enabled && $requested_land === 'live'; + if ($video) { - $video['view_count'] = increment_video_view_count((int)$video['id']); + $video['view_count'] = $home_live_first + ? (int)($video['view_count'] ?? 0) + : increment_video_view_count((int)$video['id']); } $show_video_views = setting_bool('public_show_video_views', true); @@ -33,9 +41,6 @@ $public_stats = $show_page_stats ? public_page_stats() : [ 'sources' => 0, 'views' => $total_public_views, ]; -$live_enabled = live_enabled(); -$live_url = $live_enabled ? live_embed_url() : ''; -$live_title = live_embed_title(); $per_page = (int)setting('catalogue_per_page', '10'); $page = max(1, (int)($_GET['page'] ?? 1)); @@ -55,15 +60,22 @@ foreach ($player_sources as $player_source) { } $site_title = setting('site_title', 'Ty Clifford'); -$share_title = $video ? $video['title'] . ' — ' . $site_title : 'Media — ' . $site_title; -$share_description = $video && trim($video['description'] ?? '') !== '' - ? trim($video['description']) - : setting('site_sub', 'tyclifford.com / media'); -$share_url = $video ? public_absolute_url(public_video_url($video['slug'])) : public_absolute_url(public_home_url()); -$share_image = ($video && !empty($video['thumbnail'])) ? public_absolute_url(public_media_url($video['thumbnail'])) : ''; +if ($home_live_first) { + $share_title = $live_title . ' — ' . $site_title; + $share_description = setting('site_sub', 'tyclifford.com / media'); + $share_url = public_absolute_url(media_append_query(public_home_url(), ['land' => 'live'])); + $share_image = ''; +} else { + $share_title = $video ? $video['title'] . ' — ' . $site_title : 'Media — ' . $site_title; + $share_description = $video && trim($video['description'] ?? '') !== '' + ? trim($video['description']) + : setting('site_sub', 'tyclifford.com / media'); + $share_url = $video ? public_absolute_url(public_video_url($video['slug'])) : public_absolute_url(public_home_url()); + $share_image = ($video && !empty($video['thumbnail'])) ? public_absolute_url(public_media_url($video['thumbnail'])) : ''; +} $share_image_width = 0; $share_image_height = 0; -if ($video && !empty($video['thumbnail']) && function_exists('getimagesize')) { +if (!$home_live_first && $video && !empty($video['thumbnail']) && function_exists('getimagesize')) { $share_image_file = MEDIA_DIR . ltrim($video['thumbnail'], '/'); if (is_file($share_image_file)) { $share_image_size = @getimagesize($share_image_file); @@ -76,9 +88,9 @@ if ($video && !empty($video['thumbnail']) && function_exists('getimagesize')) { $share_meta = [ 'description' => $share_description, 'url' => $share_url, - 'type' => $video ? 'video.other' : 'website', + 'type' => ($video && !$home_live_first) ? 'video.other' : 'website', 'image' => $share_image, - 'image_alt' => $video ? $video['title'] : $site_title, + 'image_alt' => $home_live_first ? $live_title : ($video ? $video['title'] : $site_title), 'image_width' => $share_image_width, 'image_height' => $share_image_height, ]; @@ -304,11 +316,11 @@ render_head($share_title, '
- - + +
-