From ccd56b1a6df8f45dd820013d4bda20390de08743 Mon Sep 17 00:00:00 2001 From: Jason Farber Date: Thu, 17 Oct 2024 11:55:52 -0400 Subject: [PATCH] Adding a new tutorial about AI Image generation. Updating the Stream component so it supports full URL thumbnails. Updating the parameter so it's intuitive. --- src/components/Stream.astro | 22 ++++++++++++------ .../tutorials/build-a-comments-api/index.mdx | 2 +- .../get-started/video-series/app-frontend.mdx | 2 +- .../get-started/video-series/deploy-app.mdx | 2 +- .../video-series/durable-objects.mdx | 2 +- .../get-started/video-series/intro.mdx | 2 +- .../video-series/make-answer-webrtc-calls.mdx | 2 +- .../video-series/real-time-messaging.mdx | 2 +- .../video-series/serverless-websocket.mdx | 2 +- .../framework-guides/deploy-a-hono-site.mdx | 3 +-- .../index.mdx | 2 +- .../docs/style-guide/components/stream.mdx | 4 ++-- ...ers-ai-models-using-a-jupyter-notebook.mdx | 2 +- .../tutorials/image-generator-flux.mdx | 23 +++++++++++++++++++ .../fundamentals/what-is-cloudflare.mdx | 2 +- src/content/videos/index.yaml | 15 +++++++++++- 16 files changed, 66 insertions(+), 23 deletions(-) create mode 100644 src/content/docs/workers-ai/tutorials/image-generator-flux.mdx diff --git a/src/components/Stream.astro b/src/components/Stream.astro index 415554d9a8e52b..5ff964f85654f5 100644 --- a/src/components/Stream.astro +++ b/src/components/Stream.astro @@ -2,10 +2,10 @@ interface Props { videoId: string; videoTitle: string; - thumbnailStartTime: string; + thumbnailTimeOrURL: string; } -const { videoId, videoTitle, thumbnailStartTime } = Astro.props; +const { videoId, videoTitle, thumbnailTimeOrURL } = Astro.props; const customerId = "1mwganm1ma0xgnmj"; const baseUrl = `https://customer-${customerId}.cloudflarestream.com/`; @@ -14,11 +14,18 @@ const url = new URL(`${videoId}/iframe`, baseUrl); url.searchParams.set("preload", "true"); url.searchParams.set("letterboxColor", "transparent"); -const thumbnailUrl = new URL(`${videoId}/thumbnails/thumbnail.jpg`, baseUrl); -thumbnailUrl.searchParams.set("fit", "crop"); -thumbnailUrl.searchParams.set("time", thumbnailStartTime); -url.searchParams.set("poster", encodeURI(thumbnailUrl.toString())); +// full url option +if (!thumbnailTimeOrURL.startsWith("http")) { + const thumbnailUrl = new URL(`${videoId}/thumbnails/thumbnail.jpg`, baseUrl); + thumbnailUrl.searchParams.set("fit", "crop"); + thumbnailUrl.searchParams.set("time", thumbnailTimeOrURL); + + url.searchParams.set("poster", encodeURI(thumbnailUrl.toString())); +} else { + url.searchParams.set("poster", thumbnailTimeOrURL); +} + ---
@@ -28,8 +35,9 @@ url.searchParams.set("poster", encodeURI(thumbnailUrl.toString())); allow="accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture;" allowfullscreen="true" title={videoTitle} - id={videoId}> + id={videoId}>
+Watch more videos on our Developer Channel